isaacscript 1.2.45 → 2.0.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 (104) hide show
  1. package/.cspell-base.json +38 -0
  2. package/.cspell-check-unused.json +7 -0
  3. package/.cspell.json +51 -35
  4. package/.eslintrc.js +14 -10
  5. package/.gitattributes +3 -3
  6. package/.github/workflows/ci.yml +3 -4
  7. package/.prettierignore +5 -0
  8. package/.prettierrc.js +19 -5
  9. package/.vscode/extensions.json +2 -3
  10. package/.vscode/settings.json +26 -15
  11. package/README.md +3 -3
  12. package/build.sh +2 -2
  13. package/check-file-updates.sh +56 -0
  14. package/check-gitignore.sh +26 -0
  15. package/check-orphaned-words.sh +53 -0
  16. package/dist/package.json +6 -6
  17. package/dist/src/checkForWindowsTerminalBugs.js +8 -7
  18. package/dist/src/checkForWindowsTerminalBugs.js.map +1 -1
  19. package/dist/src/commands/init/createMod.js +13 -8
  20. package/dist/src/commands/init/createMod.js.map +1 -1
  21. package/dist/src/commands/init/getModsDir.js +4 -5
  22. package/dist/src/commands/init/getModsDir.js.map +1 -1
  23. package/dist/src/commands/init/getProjectPath.js +5 -5
  24. package/dist/src/commands/init/getProjectPath.js.map +1 -1
  25. package/dist/src/commands/init/git.js +2 -2
  26. package/dist/src/commands/init/git.js.map +1 -1
  27. package/dist/src/commands/init/promptSaveSlot.js +3 -4
  28. package/dist/src/commands/init/promptSaveSlot.js.map +1 -1
  29. package/dist/src/commands/init/promptVSCode.js +1 -2
  30. package/dist/src/commands/init/promptVSCode.js.map +1 -1
  31. package/dist/src/commands/monitor/copyWatcherMod.js +9 -11
  32. package/dist/src/commands/monitor/copyWatcherMod.js.map +1 -1
  33. package/dist/src/commands/monitor/monitor.js +3 -4
  34. package/dist/src/commands/monitor/monitor.js.map +1 -1
  35. package/dist/src/commands/monitor/notifyGame.js +3 -3
  36. package/dist/src/commands/monitor/notifyGame.js.map +1 -1
  37. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +8 -8
  38. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
  39. package/dist/src/exec.js +2 -3
  40. package/dist/src/exec.js.map +1 -1
  41. package/dist/src/file.js +16 -1
  42. package/dist/src/file.js.map +1 -1
  43. package/dist/src/prompt.js +5 -7
  44. package/dist/src/prompt.js.map +1 -1
  45. package/dist/src/utils.js +1 -1
  46. package/dist/src/validateNodeVersion.js +4 -3
  47. package/dist/src/validateNodeVersion.js.map +1 -1
  48. package/eslint-debug.sh +8 -0
  49. package/file-templates/dynamic/README.md +2 -2
  50. package/file-templates/dynamic/main.ts +7 -5
  51. package/file-templates/dynamic/metadata.vdf +1 -1
  52. package/file-templates/dynamic/metadata.xml +3 -3
  53. package/file-templates/dynamic/package.json +1 -1
  54. package/file-templates/static/.cspell-check-unused.json +9 -0
  55. package/file-templates/static/.cspell.json.template +9 -0
  56. package/file-templates/static/.eslintrc.js +11 -10
  57. package/file-templates/static/.gitattributes +3 -3
  58. package/file-templates/static/.github/workflows/ci.yml +4 -5
  59. package/file-templates/static/.prettierignore +10 -1
  60. package/file-templates/static/.prettierrc.js +19 -5
  61. package/file-templates/static/.vscode/extensions.json +2 -3
  62. package/file-templates/static/.vscode/settings.json +26 -14
  63. package/file-templates/static/build.sh +2 -2
  64. package/file-templates/static/check-orphaned-words.sh +53 -0
  65. package/file-templates/static/lint.sh +17 -16
  66. package/file-templates/static/nuke.sh +1 -1
  67. package/file-templates/static/publish.sh +1 -1
  68. package/file-templates/static/run.sh +1 -1
  69. package/file-templates/static/src/bundleEntry.ts +4 -4
  70. package/file-templates/static/tsconfig.eslint.json +3 -3
  71. package/file-templates/static/tsconfig.json +8 -10
  72. package/file-templates/static/update.sh +1 -1
  73. package/file-templates/static-alt/.cspell-base.json +38 -0
  74. package/file-templates/static-alt/.cspell-check-unused-base.json +7 -0
  75. package/file-templates/static-alt/.prettierignore-base +5 -0
  76. package/file-templates/static-alt/.prettierrc-base.js +29 -0
  77. package/file-templates/static-alt/.vscode/extensions-typescript.json +9 -0
  78. package/file-templates/static-alt/.vscode/settings-typescript.json +63 -0
  79. package/isaacscript-watcher/README.md +3 -2
  80. package/isaacscript-watcher/main.lua +31 -41
  81. package/lint.sh +19 -16
  82. package/nuke.sh +1 -1
  83. package/package.json +6 -6
  84. package/publish.sh +1 -1
  85. package/src/checkForWindowsTerminalBugs.ts +8 -7
  86. package/src/commands/init/createMod.ts +14 -8
  87. package/src/commands/init/getModsDir.ts +4 -5
  88. package/src/commands/init/getProjectPath.ts +5 -5
  89. package/src/commands/init/git.ts +2 -2
  90. package/src/commands/init/promptSaveSlot.ts +3 -4
  91. package/src/commands/init/promptVSCode.ts +1 -2
  92. package/src/commands/monitor/copyWatcherMod.ts +9 -11
  93. package/src/commands/monitor/monitor.ts +3 -4
  94. package/src/commands/monitor/notifyGame.ts +3 -3
  95. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +8 -8
  96. package/src/exec.ts +2 -3
  97. package/src/file.ts +25 -0
  98. package/src/prompt.ts +5 -7
  99. package/src/utils.ts +1 -1
  100. package/src/validateNodeVersion.ts +5 -4
  101. package/tsconfig.eslint.json +3 -3
  102. package/tsconfig.json +9 -11
  103. package/update.sh +1 -1
  104. package/file-templates/static/.cspell.json +0 -11
@@ -9,13 +9,13 @@ import * as file from "../../file";
9
9
  import { Config } from "../../types/Config";
10
10
 
11
11
  export function copyWatcherMod(config: Config, verbose: boolean): void {
12
- // Check to see if this mod was disabled
12
+ // Check to see if this mod was disabled.
13
13
  const watcherModPath = path.join(config.modsDirectory, WATCHER_MOD_NAME);
14
14
  const disableItPath = path.join(watcherModPath, DISABLE_IT_FILE);
15
15
  const watcherModDisabled = file.exists(disableItPath, verbose);
16
16
 
17
- // Delete and re-copy the watcher mod every time IsaacScript starts
18
- // This ensures that it is always the latest version
17
+ // Delete and re-copy the watcher mod every time IsaacScript starts. This ensures that it is
18
+ // always the latest version.
19
19
  if (file.exists(watcherModPath, verbose)) {
20
20
  file.deleteFileOrDirectory(watcherModPath, verbose);
21
21
  }
@@ -23,21 +23,19 @@ export function copyWatcherMod(config: Config, verbose: boolean): void {
23
23
  file.copy(WATCHER_MOD_SOURCE_PATH, watcherModPath, verbose);
24
24
 
25
25
  if (watcherModDisabled) {
26
- // Since we deleted the directory, the "disable.it" file was deleted
27
- // Restore it
26
+ // Since we deleted the directory, the "disable.it" file was deleted. Restore it.
28
27
  file.write(disableItPath, "", verbose);
29
28
  }
30
29
 
31
- // By default, the IsaacScript watcher mod automatically restarts the game,
32
- // so we only need to disable it if the config option is explicitly set to false
30
+ // By default, the IsaacScript watcher mod automatically restarts the game, so we only need to
31
+ // disable it if the config option is explicitly set to false.
33
32
  if (config.enableIsaacScriptWatcherAutoRestart === false) {
34
33
  disableIsaacScriptWatcherAutomaticRestart(watcherModPath, verbose);
35
34
  }
36
35
 
37
- // If we copied a new version of the watcher mod into place,
38
- // but the user currently has the game open, then the old version will stay loaded
39
- // However, if the watcher mod reloads itself, the game will crash,
40
- // so there is no automated solution for this
36
+ // If we copied a new version of the watcher mod into place, but the user currently has the game
37
+ // open, then the old version will stay loaded. However, if the watcher mod reloads itself, the
38
+ // game will crash, so there is no automated solution for this.
41
39
  }
42
40
 
43
41
  function disableIsaacScriptWatcherAutomaticRestart(
@@ -39,8 +39,8 @@ export function monitor(argv: Record<string, unknown>, config: Config): void {
39
39
  copyWatcherMod(config, verbose);
40
40
  touchWatcherSaveDatFiles(config, verbose);
41
41
 
42
- // Delete and re-copy the mod every time IsaacScript starts
43
- // This ensures that it is always the latest version
42
+ // Delete and re-copy the mod every time IsaacScript starts. This ensures that it is always the
43
+ // latest version.
44
44
  if (file.exists(modTargetPath, verbose)) {
45
45
  file.deleteFileOrDirectory(modTargetPath, true);
46
46
  }
@@ -82,8 +82,7 @@ function spawnModDirectorySyncer(config: Config) {
82
82
  notifyGame.msg(msg);
83
83
 
84
84
  // If the "main.lua" file was successfully copied over, we also have to tell isaacscript-watcher
85
- // to reload the mod
86
- // Look for something like: "File synced: \main.lua"
85
+ // to reload the mod. Look for something like: "File synced: \main.lua"
87
86
  if (msg === `${FILE_SYNCED_MESSAGE} ${path.sep}${MAIN_LUA}`) {
88
87
  notifyGame.command(`luamod ${modTargetName}`);
89
88
  notifyGame.command("restart");
@@ -13,12 +13,12 @@ export function msg(data: string): void {
13
13
  continue;
14
14
  }
15
15
 
16
- // Ignore the final message from tstl upon exiting the program
16
+ // Ignore the final message from tstl upon exiting the program.
17
17
  if (trimmedLine === "Terminate batch job (Y/N)?") {
18
18
  return;
19
19
  }
20
20
 
21
- // Add a time prefix
21
+ // Add a time prefix.
22
22
  const formattedLine = `[${getTime()}] ${trimmedLine}`;
23
23
 
24
24
  sendMsgToSaveDatWriter({
@@ -27,7 +27,7 @@ export function msg(data: string): void {
27
27
  });
28
28
 
29
29
  // We also print the message to standard out so that the end-user can choose between reading
30
- // tstl errors from the IsaacScript terminal window or from looking at the in-game output
30
+ // tstl errors from the IsaacScript terminal window or from looking at the in-game output.
31
31
  printMsgToStandardOut(formattedLine);
32
32
  }
33
33
  }
@@ -41,14 +41,14 @@ function init(verbose: boolean) {
41
41
  function onMessage(type: SaveDatMessageType, data: string, numRetries = 0) {
42
42
  const saveDat = readSaveDatFromDisk(VERBOSE);
43
43
  if (saveDat.length > MAX_MESSAGES) {
44
- // If IsaacScript is running and
45
- // 1) the game is not open
46
- // 2) or the game is open but the IsaacScript Watcher mod is disabled
47
- // then this process will continue to write to the "save#.dat" file,
48
- // which can cause it to grow arbitrarily large
49
- // (since there is no-one on the other side removing the messages)
50
- // If there is N messages already in the queue,
51
- // assume that no-one is listening and stop adding any more messages
44
+ // If IsaacScript is running and:
45
+ // - the game is not open
46
+ // - or the game is open but the IsaacScript Watcher mod is disabled
47
+ //
48
+ // Then this process will continue to write to the "save#.dat" file, which can cause it to grow
49
+ // arbitrarily large (since there is no-one on the other side removing the messages). If there
50
+ // is N messages already in the queue, assume that no-one is listening and stop adding any more
51
+ // messages.
52
52
  return;
53
53
  }
54
54
  addMessageToSaveDat(type, saveDat, data); // Mutates saveDat
package/src/exec.ts CHANGED
@@ -60,9 +60,8 @@ export function execShell(
60
60
  allowFailure = false,
61
61
  cwd = CWD,
62
62
  ): [exitStatus: number, stdout: string] {
63
- // On Windows, "spawnSync()" will not account for spaces in arguments
64
- // Thus, wrap everything in a double quote
65
- // This will cause arguments that naturally have double quotes to fail
63
+ // On Windows, "spawnSync()" will not account for spaces in arguments. Thus, wrap everything in a
64
+ // double quote. This will cause arguments that naturally have double quotes to fail.
66
65
  if (command.includes('"')) {
67
66
  error(
68
67
  "execShell cannot execute commands with double quotes in the command.",
package/src/file.ts CHANGED
@@ -160,6 +160,31 @@ export function read(filePath: string, verbose: boolean): string {
160
160
  return fileContents;
161
161
  }
162
162
 
163
+ export function rename(
164
+ srcPath: string,
165
+ dstPath: string,
166
+ verbose: boolean,
167
+ ): void {
168
+ if (verbose) {
169
+ console.log(`Renaming: ${srcPath} --> ${dstPath}`);
170
+ }
171
+
172
+ try {
173
+ fs.renameSync(srcPath, dstPath);
174
+ } catch (err) {
175
+ error(
176
+ `Failed to rename "${chalk.green(srcPath)}" to "${chalk.green(
177
+ dstPath,
178
+ )}":`,
179
+ err,
180
+ );
181
+ }
182
+
183
+ if (verbose) {
184
+ console.log(`Renamed: ${srcPath} --> ${dstPath}`);
185
+ }
186
+ }
187
+
163
188
  export function touch(filePath: string, verbose: boolean): void {
164
189
  if (verbose) {
165
190
  console.log(`Touching: ${filePath}`);
package/src/prompt.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  // Both the Inquirer.js library and the Prompts library have a bug where text is duplicated in a Git
2
- // Bash terminal
3
- // Thus, we revert to using the simpler Prompt library
2
+ // Bash terminal. Thus, we revert to using the simpler Prompt library.
4
3
 
5
4
  import chalk from "chalk";
6
5
  import prompt from "prompt";
@@ -10,7 +9,7 @@ const VALID_YES_RESPONSES = new Set(["yes", "ye", "y"]);
10
9
  const VALID_NO_RESPONSES = new Set(["no", "n"]);
11
10
 
12
11
  export function promptInit(): void {
13
- // Override some of the prompt library's default values
12
+ // Override some of the prompt library's default values:
14
13
  // https://github.com/flatiron/prompt#customizing-your-prompt
15
14
  prompt.message = chalk.green("?");
16
15
  prompt.delimiter = " ";
@@ -23,7 +22,7 @@ export async function getInputYesNo(
23
22
  ): Promise<boolean> {
24
23
  prompt.start();
25
24
 
26
- // Capitalize the letter that represents the default option
25
+ // Capitalize the letter that represents the default option.
27
26
  const y = defaultValue ? "Y" : "y";
28
27
  const n = defaultValue ? "n" : "N";
29
28
 
@@ -46,7 +45,7 @@ export async function getInputYesNo(
46
45
 
47
46
  const cleanedResponse = response.toLowerCase().trim();
48
47
 
49
- // Default to true
48
+ // Default to true.
50
49
  if (cleanedResponse === "") {
51
50
  return defaultValue;
52
51
  }
@@ -59,8 +58,7 @@ export async function getInputYesNo(
59
58
  return false;
60
59
  }
61
60
 
62
- error('Invalid response; must answer "yes" or "no".');
63
- return false;
61
+ return error('Invalid response; must answer "yes" or "no".');
64
62
  }
65
63
 
66
64
  /** Returns trimmed input. */
package/src/utils.ts CHANGED
@@ -33,7 +33,7 @@ export function isKebabCase(s: string): boolean {
33
33
  }
34
34
 
35
35
  /**
36
- * parseIntSafe is a more reliable version of parseInt. By default, "parseInt('1a')" will return
36
+ * `parseIntSafe` is a more reliable version of `parseInt`. By default, "parseInt('1a')" will return
37
37
  * "1", which is unexpected. This returns either an integer or NaN.
38
38
  */
39
39
  export function parseIntSafe(input: unknown): number {
@@ -4,13 +4,14 @@ import { parseSemVer } from "./utils";
4
4
 
5
5
  const REQUIRED_NODE_JS_MAJOR_VERSION = 16;
6
6
 
7
- // This program requires Node to be at least v16.0.0,
8
- // since that is the version that added the "fs.rmSync()" function
9
- // (I tested on Node v15.0.0 and it failed)
7
+ /**
8
+ * This program requires Node to be at least v16.0.0, since that is the version that added the
9
+ * "fs.rmSync" function. (Node v15.0.0 is confirmed to not work.)
10
+ */
10
11
  export function validateNodeVersion(): void {
11
12
  const { version } = process;
12
- const [majorVersion] = parseSemVer(version);
13
13
 
14
+ const [majorVersion] = parseSemVer(version);
14
15
  if (majorVersion >= REQUIRED_NODE_JS_MAJOR_VERSION) {
15
16
  return;
16
17
  }
@@ -1,11 +1,11 @@
1
- // A special TypeScript configuration file, used by ESLint only
1
+ // A special TypeScript configuration file, used by ESLint only.
2
2
  {
3
3
  "extends": "./tsconfig.json",
4
4
  "include": [
5
- // This must match the "include" setting in the "tsconfig.json" file
5
+ // This must match the "include" setting in the "tsconfig.json" file.
6
6
  "./src/**/*.ts",
7
7
 
8
- // These are ESLint-only inclusions
8
+ // These are ESLint-only inclusions.
9
9
  "./.eslintrc.js",
10
10
  ],
11
11
  }
package/tsconfig.json CHANGED
@@ -1,23 +1,21 @@
1
- // The configuration file for TypeScript
1
+ // The configuration file for TypeScript.
2
2
  {
3
- // We extend the standard IsaacScript config
3
+ // We extend the standard IsaacScript config:
4
4
  // https://github.com/IsaacScript/isaacscript-tsconfig/blob/main/tsconfig.node.json
5
5
  "extends": "isaacscript-tsconfig/tsconfig.node.json",
6
6
 
7
7
  // https://www.typescriptlang.org/docs/handbook/compiler-options.html
8
8
  "compilerOptions": {
9
- // "outDir" specifies the output directory
10
- // By default, it will put the compiled ".js" next to the respective ".ts" file,
11
- // which will clutter the "src" directory
9
+ // "outDir" specifies the output directory.
10
+ // By default, it will put the compiled ".js" next to the respective ".ts" file, which will
11
+ // clutter the "src" directory.
12
12
  "outDir": "./dist",
13
13
 
14
- // We need to import the "package.json" file to see what version we are running
15
- // By default, this is false
14
+ // We need to import the "package.json" file to see what version we are running.
15
+ // By default, this is false.
16
16
  "resolveJsonModule": true,
17
17
  },
18
18
 
19
- // A list of the TypeScript files to compile
20
- "include": [
21
- "./src/**/*.ts",
22
- ],
19
+ // A list of the TypeScript files to compile.
20
+ "include": ["./src/**/*.ts"],
23
21
  }
package/update.sh CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e # Exit on any errors
4
4
 
5
- # Get the directory of this script
5
+ # Get the directory of this script:
6
6
  # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
7
  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
8
 
@@ -1,11 +0,0 @@
1
- {
2
- "version": "0.2",
3
- "words": [
4
- "dbaeumer",
5
- "isaacscript",
6
- "sarisia",
7
- "steamapps",
8
- "technote",
9
- "tstl"
10
- ]
11
- }