isaacscript 2.0.14-dev.1 → 2.0.14-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/file-templates/dynamic/README.md +3 -0
  2. package/file-templates/dynamic/gitignore +144 -0
  3. package/file-templates/dynamic/main.ts +19 -0
  4. package/file-templates/dynamic/metadata.vdf +6 -0
  5. package/file-templates/dynamic/metadata.xml +8 -0
  6. package/file-templates/dynamic/package.json +20 -0
  7. package/file-templates/static/.cspell.json.template +21 -0
  8. package/file-templates/static/.env_template +2 -0
  9. package/file-templates/static/.eslintrc.js +24 -0
  10. package/file-templates/static/.gitattributes +9 -0
  11. package/file-templates/static/.github/workflows/ci.yml +53 -0
  12. package/file-templates/static/.prettierignore +14 -0
  13. package/file-templates/static/.prettierrc.js +42 -0
  14. package/file-templates/static/.vscode/extensions.json +10 -0
  15. package/file-templates/static/.vscode/settings.json +79 -0
  16. package/file-templates/static/LICENSE +674 -0
  17. package/file-templates/static/build.sh +15 -0
  18. package/file-templates/static/check-orphaned-words.sh +58 -0
  19. package/file-templates/static/lint.sh +39 -0
  20. package/file-templates/static/nuke.sh +18 -0
  21. package/file-templates/static/plugins/addCrashDebugStatements.ts +40 -0
  22. package/file-templates/static/plugins/addIsaacScriptCommentHeader.ts +37 -0
  23. package/file-templates/static/plugins/noExtendedEnums.ts +69 -0
  24. package/file-templates/static/publish.sh +10 -0
  25. package/file-templates/static/run.sh +10 -0
  26. package/file-templates/static/src/bundleEntry.ts +10 -0
  27. package/file-templates/static/tsconfig.eslint.json +11 -0
  28. package/file-templates/static/tsconfig.json +33 -0
  29. package/file-templates/static/update.sh +21 -0
  30. package/file-templates/static-alt/.prettierignore-base +5 -0
  31. package/file-templates/static-alt/.prettierrc-base.js +30 -0
  32. package/file-templates/static-alt/.vscode/extensions-typescript.json +9 -0
  33. package/file-templates/static-alt/.vscode/settings-typescript.json +66 -0
  34. package/file-templates/static-alt/check-file-updates.sh +67 -0
  35. package/isaacscript-watcher/.luacheckrc +96 -0
  36. package/isaacscript-watcher/README.md +8 -0
  37. package/isaacscript-watcher/main.lua +270 -0
  38. package/isaacscript-watcher/metadata.xml +7 -0
  39. package/isaacscript-watcher/resources/gfx/logo.anm2 +27 -0
  40. package/isaacscript-watcher/resources/gfx/logo.png +0 -0
  41. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ SECONDS=0
10
+
11
+ # Convert the TypeScript to a single Lua file (based on the settings in "tsconfig.json").
12
+ cd "$DIR"
13
+ npx tstl
14
+
15
+ echo "Successfully built in $SECONDS seconds."
@@ -0,0 +1,58 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ REPO_ROOT="$DIR"
10
+ cd "$REPO_ROOT"
11
+
12
+ # Do nothing if the configuration file does not exist.
13
+ CSPELL_CONFIG_NAME=".cspell.json"
14
+ CSPELL_CONFIG_PATH="$REPO_ROOT/$CSPELL_CONFIG_NAME"
15
+ if ! test -f "$CSPELL_CONFIG_PATH"; then
16
+ echo "The \"$CSPELL_CONFIG_NAME\" file does not exist. Skipping checks."
17
+ exit 0
18
+ fi
19
+
20
+ # Do nothing if the configuration file does not have any words in it.
21
+ if ! grep -q '"words": ' "$CSPELL_CONFIG_PATH"; then
22
+ echo "The \"$CSPELL_CONFIG_NAME\" file does not have any whitelisted words in it. Skipping checks."
23
+ exit 0
24
+ fi
25
+
26
+ # Make a list of every misspelled word without any custom words.
27
+ # We need to move the configuration path temporarily or else the cspell command won't work properly.
28
+ CSPELL_CONFIG_WORDS=$(cat "$CSPELL_CONFIG_PATH" | python -c "import sys, json; print('\n'.join(json.load(sys.stdin)['words']))")
29
+ CSPELL_CONFIG_WITHOUT_WORDS=$(cat "$CSPELL_CONFIG_PATH" | python -c "import sys, json; config = json.load(sys.stdin); del config['words']; print(json.dumps(config))")
30
+ CSPELL_CONFIG_PATH_TEMP="$REPO_ROOT/.cspell-temp.json"
31
+ mv "$CSPELL_CONFIG_PATH" "$CSPELL_CONFIG_PATH_TEMP"
32
+ echo "$CSPELL_CONFIG_WITHOUT_WORDS" > "$CSPELL_CONFIG_PATH"
33
+ MISSPELLED_WORDS_PATH="/tmp/misspelled-words.txt"
34
+ npx cspell lint --no-progress --no-summary --unique --words-only | sort --ignore-case --unique > "$MISSPELLED_WORDS_PATH"
35
+ mv "$CSPELL_CONFIG_PATH_TEMP" "$CSPELL_CONFIG_PATH"
36
+
37
+ # Check that each ".cspell.json" word is actually being used.
38
+ echo "Checking for orphaned CSpell configuration words in: $CSPELL_CONFIG_PATH"
39
+
40
+ ONE_OR_MORE_FAILURES=0
41
+ set +e
42
+ for LINE in $CSPELL_CONFIG_WORDS; do
43
+ LINE_TRIMMED=$(echo "$LINE" | xargs)
44
+ if ! grep "$LINE_TRIMMED" "$MISSPELLED_WORDS_PATH" --ignore-case --quiet; then
45
+ echo "The following word in the CSpell config is not being used: $LINE_TRIMMED"
46
+ ONE_OR_MORE_FAILURES=1
47
+ fi
48
+ done
49
+ set -e
50
+
51
+ rm -f "$MISSPELLED_WORDS_PATH"
52
+
53
+ if [ $ONE_OR_MORE_FAILURES -ne "0" ]; then
54
+ echo "CSpell configuration words are not valid."
55
+ exit 1
56
+ fi
57
+
58
+ echo "CSpell configuration words are valid."
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ SECONDS=0
10
+
11
+ cd "$DIR"
12
+
13
+ # Step 1 - Use Prettier to check formatting.
14
+ npx prettier --check .
15
+
16
+ # Step 2 - Use ESLint to lint the TypeScript.
17
+ # Since all ESLint errors are set to warnings, we set max warnings to 0 so that warnings will fail
18
+ # in CI.
19
+ npx eslint --max-warnings 0 src
20
+
21
+ # Step 3 - Spell check every file using cspell.
22
+ # We use "--no-progress" and "--no-summary" because we want to only output errors.
23
+ npx cspell --no-progress --no-summary
24
+
25
+ # Step 4 - Use xmllint to lint XML files.
26
+ # (Skip this step if xmllint is not currently installed for whatever reason.)
27
+ if command -v xmllint &> /dev/null; then
28
+ find "$DIR/mod" -name "*.xml" -print0 | xargs -0 xmllint --noout
29
+ fi
30
+
31
+ # Step 5 - Check for unused imports.
32
+ # The "--error" flag makes it return an error code of 1 if unused exports are found.
33
+ # (This starts out disabled by default, but you can uncomment the following line to find dead code.)
34
+ # npx ts-prune --error
35
+
36
+ # Step 6 - Check for orphaned words.
37
+ bash "$DIR/check-orphaned-words.sh"
38
+
39
+ echo "Successfully linted in $SECONDS seconds."
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ PACKAGE_LOCK="$DIR/package-lock.json"
10
+ rm -f "$PACKAGE_LOCK"
11
+ echo "Successfully deleted: $PACKAGE_LOCK"
12
+
13
+ NODE_MODULES="$DIR/node_modules"
14
+ rm -rf "$NODE_MODULES"
15
+ echo "Successfully deleted: $NODE_MODULES"
16
+
17
+ npm install
18
+ echo "Successfully reinstalled Node dependencies."
@@ -0,0 +1,40 @@
1
+ /**
2
+ * When you write code that causes the game to crash, it can be difficult to find the exact line of
3
+ * code that is causing the crash.
4
+ *
5
+ * In these situations, you can enable this plugin, which will add a log statement in between every
6
+ * line of Lua code with a randomly-generated UUID. That way, you can cause the crash, and then look
7
+ * at the bottom of the "log.txt" for the final UUID that shows up.
8
+ *
9
+ * Next, you can Ctrl + f in the "main.lua" file for the matching UUID, which will bring you to the
10
+ * exact point in the code where the crash happened.
11
+ */
12
+
13
+ import * as crypto from "crypto";
14
+ import { SourceNode } from "source-map";
15
+ import * as ts from "typescript";
16
+ import * as tstl from "typescript-to-lua";
17
+
18
+ class CustomPrinter extends tstl.LuaPrinter {
19
+ printStatement(statement: tstl.Statement): SourceNode {
20
+ const uuid = crypto.randomUUID();
21
+ const debugLineToInsert = `Isaac.DebugString("CRASH DEBUG ${uuid}")\n`;
22
+ const originalResult = super.printStatement(statement);
23
+ return this.createSourceNode(statement, [
24
+ debugLineToInsert,
25
+ originalResult,
26
+ ]);
27
+ }
28
+ }
29
+
30
+ const plugin: tstl.Plugin = {
31
+ printer: (
32
+ program: ts.Program,
33
+ emitHost: tstl.EmitHost,
34
+ fileName: string,
35
+ file: tstl.File,
36
+ ) => new CustomPrinter(emitHost, program, fileName).print(file),
37
+ };
38
+
39
+ // ts-prune-ignore-next
40
+ export default plugin;
@@ -0,0 +1,37 @@
1
+ /** This plugin adds an explanatory header to the top of the generated Lua code. */
2
+
3
+ import * as ts from "typescript";
4
+ import * as tstl from "typescript-to-lua";
5
+
6
+ const INFORMATIONAL_HEADER = `--[[
7
+
8
+ This Isaac mod was created with the IsaacScript tool.
9
+
10
+ The Lua code in this file is not actually the source code for the program. Rather, it was
11
+ automatically generated from higher-level TypeScript code, and might be hard to read. If you want to
12
+ understand how the code in this mod works, you should read the actual TypeScript source code
13
+ directly instead of trying to read this file. Usually, the link to the source code can be found in
14
+ the mod's description on the Steam Workshop. If not, you can ask the mod author directly if the
15
+ source code is publicly available.
16
+
17
+ IsaacScript provides a lot of advantages over using raw Lua. For more information about the tool,
18
+ see the official website: https://isaacscript.github.io/
19
+
20
+ --]]
21
+
22
+ `;
23
+
24
+ const plugin: tstl.Plugin = {
25
+ beforeEmit(
26
+ _program: ts.Program,
27
+ _options: tstl.CompilerOptions,
28
+ _emitHost: tstl.EmitHost,
29
+ result: tstl.EmitFile[],
30
+ ) {
31
+ for (const file of result) {
32
+ file.code = `${INFORMATIONAL_HEADER}${file.code}`;
33
+ }
34
+ },
35
+ };
36
+
37
+ export default plugin;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * This plugin prevents transpiled enums from using global variables as a base (if present).
3
+ *
4
+ * For example, by default, the following enum:
5
+ *
6
+ * ```ts
7
+ * export enum Foo {
8
+ * Value1,
9
+ * Value2,
10
+ * }
11
+ * ```
12
+ *
13
+ * Will be transpiled to this:
14
+ *
15
+ * ```lua
16
+ * local ____exports = {}
17
+ * ____exports.Foo = Foo or ({})
18
+ * ____exports.Foo.Value1 = 0
19
+ * ____exports.Foo[____exports.Foo.Value1] = "Value1"
20
+ * ____exports.Foo.Value2 = 1
21
+ * ____exports.Foo[____exports.Foo.Value2] = "Value2"
22
+ * return ____exports
23
+ * ```
24
+ *
25
+ * As we can see, the first line uses the existing global variable of "Foo" as a base, if present.
26
+ * The reason it does this is because TSTL needs to support the TypeScript feature of combining
27
+ * enums, like this:
28
+ *
29
+ * ```ts
30
+ * enum Foo {
31
+ * Value1,
32
+ * }
33
+ * enum Foo {
34
+ * Value2,
35
+ * }
36
+ * ```
37
+ *
38
+ * Unfortunately, this design decision means that local enums will essentially turn into global
39
+ * variables. This plugin removes this behavior, always making enums local variables.
40
+ */
41
+
42
+ import * as ts from "typescript";
43
+ import * as tstl from "typescript-to-lua";
44
+
45
+ const plugin: tstl.Plugin = {
46
+ visitors: {
47
+ [ts.SyntaxKind.EnumDeclaration]: (node, context) => {
48
+ // Call the normal TSTL enum transpilation method
49
+ const statements = context.superTransformStatements(node);
50
+
51
+ // Get the first element, which will be equal to something like:
52
+ // local ____exports.Foo = Foo or ({})
53
+ const oldDeclaration = statements[0];
54
+ if (
55
+ oldDeclaration !== undefined &&
56
+ tstl.isAssignmentStatement(oldDeclaration)
57
+ ) {
58
+ // Replace the right side of the assignment with a blank Lua table, e.g.
59
+ // local ____exports.Foo = {}
60
+ const blankTable = tstl.createTableExpression();
61
+ oldDeclaration.right = [blankTable];
62
+ }
63
+
64
+ return statements;
65
+ },
66
+ },
67
+ };
68
+
69
+ export default plugin;
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ cd "$DIR"
10
+ npx isaacscript publish "$@"
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ cd "$DIR"
10
+ npx isaacscript
@@ -0,0 +1,10 @@
1
+ // This is the entry point for the TypeScriptToLua bundler, which is set in the "tsconfig.json"
2
+ // file. All this file does is immediately execute the "main()" function in the "main.ts" file. (We
3
+ // don't want to point the TypeScriptToLua bundler at the "main.ts" file directly, because any
4
+ // variables or functions that are declared in a bundle entry point will become global.)
5
+
6
+ import { main } from "./main";
7
+
8
+ main();
9
+
10
+ // Do not add any code to this file!
@@ -0,0 +1,11 @@
1
+ // A special TypeScript configuration file, used by ESLint only.
2
+ {
3
+ "extends": "./tsconfig.json",
4
+ "include": [
5
+ // This must match the "include" setting in the "tsconfig.json" file.
6
+ "./src/**/*.ts",
7
+
8
+ // These are ESLint-only inclusions.
9
+ "./.eslintrc.js",
10
+ ],
11
+ }
@@ -0,0 +1,33 @@
1
+ // The configuration file for TypeScript.
2
+ {
3
+ // We extend the standard IsaacScript config:
4
+ // https://github.com/IsaacScript/isaacscript-tsconfig/blob/main/tsconfig.mod.json
5
+ "extends": "isaacscript-tsconfig/tsconfig.mod.json",
6
+
7
+ // https://www.typescriptlang.org/docs/handbook/compiler-options.html
8
+ "compilerOptions": {
9
+ // Specifies the root folder within your source files.
10
+ "rootDir": "./src",
11
+ },
12
+
13
+ // A list of the TypeScript files to compile.
14
+ "include": ["./src/**/*.ts"],
15
+
16
+ // TypeScriptToLua settings.
17
+ "tstl": {
18
+ "luaTarget": "5.3",
19
+ "luaBundle": "./mod/main.lua", // Will bundle all output Lua files into a single file.
20
+ "luaBundleEntry": "./src/bundleEntry.ts", // This invokes the "main.ts" file.
21
+ "luaPlugins": [
22
+ // A plugin to add an explanatory comment at the top of the compiled "main.lua" file.
23
+ { "name": "./plugins/addIsaacScriptCommentHeader.ts" },
24
+
25
+ // A plugin to make enums safe from global variables.
26
+ { "name": "./plugins/noExtendedEnums.ts" },
27
+
28
+ // Uncomment this and recompile the mod to enable crash debugging, which will tell you the
29
+ // exact line of the mod that is causing the crash.
30
+ // { "name": "./plugins/addCrashDebugStatements.ts" },
31
+ ],
32
+ },
33
+ }
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ cd "$DIR"
10
+
11
+ PACKAGE_JSON="$DIR/package.json"
12
+ OLD_HASH=$(md5sum "$PACKAGE_JSON")
13
+ npx npm-check-updates --upgrade --packageFile "$PACKAGE_JSON"
14
+ NEW_HASH=$(md5sum "$PACKAGE_JSON")
15
+ if [[ $OLD_HASH != $NEW_HASH ]]; then
16
+ if test -f "$DIR/yarn.lock"; then
17
+ yarn
18
+ else
19
+ npm install
20
+ fi
21
+ fi
@@ -0,0 +1,5 @@
1
+ # Ignore compiled output.
2
+ dist
3
+
4
+ # The VSCode CSpell plugin causes the file to become unformatted whenever a new word is added.
5
+ .cspell.json
@@ -0,0 +1,30 @@
1
+ // This is the configuration file for Prettier, the auto-formatter:
2
+ // https://prettier.io/docs/en/configuration.html
3
+ module.exports = {
4
+ // Always print trailing commas:
5
+ // https://prettier.io/docs/en/options.html#trailing-commas
6
+ // The default is "es5" - Trailing commas where valid in ES5 (objects, arrays, etc.). However,
7
+ // always having trailing commas is objectively better. The Airbnb style guide agrees:
8
+ // https://github.com/airbnb/javascript#commas--dangling
9
+ // Prettier itself also acknowledges Nik Graf's blog in their official blog:
10
+ // https://prettier.io/blog/2020/03/21/2.0.0.html
11
+ // https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
12
+ // Prettier will change the default in the future:
13
+ // https://github.com/prettier/prettier/issues/9369
14
+ trailingComma: "all",
15
+
16
+ // We want to always use "lf" to be consistent with all platforms.
17
+ endOfLine: "lf",
18
+
19
+ // Allow proper formatting of JSONC files:
20
+ // https://github.com/prettier/prettier/issues/5708
21
+ overrides: [
22
+ {
23
+ files: ["**/.vscode/*.json", "**/tsconfig.json", "**/tsconfig.*.json"],
24
+ options: {
25
+ parser: "json5",
26
+ quoteProps: "preserve",
27
+ },
28
+ },
29
+ ],
30
+ };
@@ -0,0 +1,9 @@
1
+ // These are Visual Studio Code extensions that are intended to be used with this particular
2
+ // repository: https://go.microsoft.com/fwlink/?LinkId=827846
3
+ {
4
+ "recommendations": [
5
+ "esbenp.prettier-vscode", // The TypeScript formatter
6
+ "dbaeumer.vscode-eslint", // The TypeScript linter
7
+ "streetsidesoftware.code-spell-checker", // A spell-checker extension based on cspell
8
+ ],
9
+ }
@@ -0,0 +1,66 @@
1
+ // These are Visual Studio Code settings that should apply to this particular repository.
2
+ {
3
+ // ----------------
4
+ // Vanilla settings
5
+ // ----------------
6
+
7
+ // This matches the Airbnb JavaScript style guide.
8
+ "editor.rulers": [100],
9
+ "editor.tabSize": 2,
10
+
11
+ // We want to always use "lf" to be consistent with all platforms.
12
+ "files.eol": "\n",
13
+
14
+ // Automatically removing all trailing whitespace when saving a file.
15
+ "files.trimTrailingWhitespace": true,
16
+
17
+ // Configure glob patterns for excluding files and folders in full text searches and quick open.
18
+ // (File extensions must be specified or the glob won't work properly.)
19
+ "search.exclude": {
20
+ "dist/**/*.ts": true,
21
+ "dist/**/*.js": true,
22
+ "dist/**/*.json": true,
23
+ },
24
+
25
+ // -----------------
26
+ // Language settings
27
+ // -----------------
28
+
29
+ // By default, VSCode will not automatically fill-in function arguments.
30
+ "javascript.suggest.completeFunctionCalls": true,
31
+ "typescript.suggest.completeFunctionCalls": true,
32
+
33
+ // Automatically run the formatter when certain files are saved.
34
+ "[javascript]": {
35
+ "editor.codeActionsOnSave": ["source.fixAll.eslint"],
36
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
37
+ "editor.formatOnSave": true,
38
+ "editor.tabSize": 2,
39
+ },
40
+ "[typescript]": {
41
+ "editor.codeActionsOnSave": ["source.fixAll.eslint"],
42
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
43
+ "editor.formatOnSave": true,
44
+ "editor.tabSize": 2,
45
+ },
46
+ "[json]": {
47
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
48
+ "editor.formatOnSave": true,
49
+ "editor.tabSize": 2,
50
+ },
51
+ "[jsonc]": {
52
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
53
+ "editor.formatOnSave": true,
54
+ "editor.tabSize": 2,
55
+ },
56
+ "[yaml]": {
57
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
58
+ "editor.formatOnSave": true,
59
+ "editor.tabSize": 2,
60
+ },
61
+ "[markdown]": {
62
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
63
+ "editor.formatOnSave": true,
64
+ "editor.tabSize": 2,
65
+ },
66
+ }
@@ -0,0 +1,67 @@
1
+ #!/bin/bash
2
+
3
+ set -e # Exit on any errors
4
+
5
+ # Get the directory of this script:
6
+ # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
+
9
+ TEMPLATE_FILES_FILE_NAME="check-file-updates.txt"
10
+ TEMPLATE_FILES_PATH="$DIR/$TEMPLATE_FILES_FILE_NAME"
11
+
12
+ # Do nothing if the metadata file does not exist.
13
+ if ! test -f "$TEMPLATE_FILES_PATH"; then
14
+ echo "The \"$TEMPLATE_FILES_FILE_NAME\" file does not exist. Skipping checks."
15
+ exit 0
16
+ fi
17
+
18
+ ONE_OR_MORE_FAILURES=0
19
+ for FILE_SPECIFICATION in $(cat "$TEMPLATE_FILES_PATH"); do
20
+ if [[ "$FILE_SPECIFICATION" =~ (.+):(.+) ]]; then
21
+ LOCAL_FILE=${BASH_REMATCH[1]}
22
+ REMOTE_FILE=${BASH_REMATCH[2]}
23
+ STATIC_DIRECTORY="static-alt"
24
+ else
25
+ LOCAL_FILE=$FILE_SPECIFICATION
26
+ REMOTE_FILE=$FILE_SPECIFICATION
27
+ STATIC_DIRECTORY="static"
28
+ fi
29
+
30
+ echo "Checking for an updated version of: $LOCAL_FILE"
31
+ TMP_FILE_PATH="/tmp/base-file"
32
+ URL="https://raw.githubusercontent.com/IsaacScript/isaacscript/main/file-templates/$STATIC_DIRECTORY/$REMOTE_FILE"
33
+ curl "$URL" --output "$TMP_FILE_PATH" --silent --show-error
34
+ if grep "^404: Not Found" "$TMP_FILE_PATH" --silent; then
35
+ echo
36
+ echo "Failed to find the following remote file:"
37
+ echo "$URL"
38
+ exit 1
39
+ fi
40
+
41
+ FILE_PATH="$DIR/$LOCAL_FILE"
42
+ if test -f "$FILE_PATH"; then
43
+ set +e
44
+ if ! cmp "$FILE_PATH" "$TMP_FILE_PATH" --silent; then
45
+ echo
46
+ echo "File \"$LOCAL_FILE\" is out of date. Get the updated version here:"
47
+ echo "$URL"
48
+ echo
49
+ diff "$FILE_PATH" "$TMP_FILE_PATH"
50
+ echo
51
+ ONE_OR_MORE_FAILURES=1
52
+ fi
53
+ set -e
54
+ else
55
+ echo "File \"$FILE_PATH\" does not exist! Change the \"$TEMPLATE_FILES_FILE_NAME\" file."
56
+ ONE_OR_MORE_FAILURES=1
57
+ fi
58
+
59
+ rm -f "$TMP_FILE_PATH"
60
+ done
61
+
62
+ if [ $ONE_OR_MORE_FAILURES -ne "0" ]; then
63
+ echo "One or more files was not valid."
64
+ exit 1
65
+ fi
66
+
67
+ echo "All core files up to date!"
@@ -0,0 +1,96 @@
1
+ -- These are all of the declarations in the "enums.lua" file in the "scripts" subdirectory,
2
+ -- sorted alphabetically
3
+ globals = {
4
+ "ActionTriggers",
5
+ "BabySubType",
6
+ "BombSubType",
7
+ "BombVariant",
8
+ "ButtonAction",
9
+ "CacheFlag",
10
+ "Card",
11
+ "Challenge",
12
+ "ChestSubType",
13
+ "CoinSubType",
14
+ "CollectibleType",
15
+ "Color",
16
+ "DamageFlag",
17
+ "Difficulty",
18
+ "Direction",
19
+ "DoorSlot",
20
+ "DoorState",
21
+ "DoorVariant",
22
+ "EffectVariant",
23
+ "EntityCollisionClass",
24
+ "EntityFlag",
25
+ "EntityGridCollisionClass",
26
+ "EntityPartition",
27
+ "EntityPtr",
28
+ "EntityRef",
29
+ "EntityType",
30
+ "FamiliarVariant",
31
+ "Font",
32
+ "Game",
33
+ "GameStateFlag",
34
+ "GetPtrHash",
35
+ "GridCollisionClass",
36
+ "GridEntityType",
37
+ "GridRooms",
38
+ "HeartSubType",
39
+ "Input",
40
+ "InputHook",
41
+ "Isaac",
42
+ "ItemConfig",
43
+ "ItemPoolType",
44
+ "ItemType",
45
+ "KColor",
46
+ "Keyboard",
47
+ "KeySubType",
48
+ "LaserOffset",
49
+ "LevelCurse",
50
+ "LevelStage",
51
+ "LevelStateFlag",
52
+ "LocustSubtypes",
53
+ "ModCallbacks",
54
+ "Mouse",
55
+ "Music",
56
+ "MusicManager",
57
+ "NpcState",
58
+ "NullItemID",
59
+ "PickupPrice",
60
+ "PickupVariant",
61
+ "PillColor",
62
+ "PillEffect",
63
+ "PlayerForm",
64
+ "PlayerItemState",
65
+ "PlayerSpriteLayer",
66
+ "PlayerType",
67
+ "ProjectileFlags",
68
+ "ProjectileParams",
69
+ "ProjectileVariant",
70
+ "Random",
71
+ "RandomVector",
72
+ "RegisterMod",
73
+ "RNG",
74
+ "RoomShape",
75
+ "RoomType",
76
+ "SeedEffect",
77
+ "SFXManager",
78
+ "SortingLayer",
79
+ "SoundEffect",
80
+ "Sprite",
81
+ "StageType",
82
+ "TearFlags",
83
+ "TearVariant",
84
+ "TrinketType",
85
+ "Vector",
86
+ "WeaponType",
87
+
88
+ -- Global variables
89
+ "ModConfigMenu",
90
+ }
91
+
92
+ max_line_length = 100
93
+
94
+ -- Luacheck complains about functions in a module declared with a colon if self is unused;
95
+ -- we may want all functions to be declared with a colon for uniformity
96
+ unused_args = false
@@ -0,0 +1,8 @@
1
+ # isaacscript-watcher
2
+
3
+ `isaacscript-watcher` is a Lua mod that listens for messages from `IsaacScript`.
4
+
5
+ It can:
6
+
7
+ - print messages to the screen
8
+ - execute console commands