isaacscript 1.2.6 → 1.2.7

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 (72) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/checkForWindowsTerminalBugs.js +2 -2
  3. package/dist/src/checkForWindowsTerminalBugs.js.map +1 -1
  4. package/dist/src/commands/copy/copy.js +4 -3
  5. package/dist/src/commands/copy/copy.js.map +1 -1
  6. package/dist/src/commands/init/checkIfProjectPathExists.js +2 -2
  7. package/dist/src/commands/init/checkIfProjectPathExists.js.map +1 -1
  8. package/dist/src/commands/init/checkModTargetDirectory.js +2 -2
  9. package/dist/src/commands/init/checkModTargetDirectory.js.map +1 -1
  10. package/dist/src/commands/init/createMod.js +3 -3
  11. package/dist/src/commands/init/createMod.js.map +1 -1
  12. package/dist/src/commands/init/getModsDir.js +6 -6
  13. package/dist/src/commands/init/getModsDir.js.map +1 -1
  14. package/dist/src/commands/init/getProjectPath.js +2 -2
  15. package/dist/src/commands/init/getProjectPath.js.map +1 -1
  16. package/dist/src/commands/init/installVSCodeExtensions.js +2 -2
  17. package/dist/src/commands/init/installVSCodeExtensions.js.map +1 -1
  18. package/dist/src/commands/init/promptSaveSlot.js +2 -2
  19. package/dist/src/commands/init/promptSaveSlot.js.map +1 -1
  20. package/dist/src/commands/monitor/getTSConfigInclude.js +4 -4
  21. package/dist/src/commands/monitor/getTSConfigInclude.js.map +1 -1
  22. package/dist/src/commands/monitor/monitor.js +13 -35
  23. package/dist/src/commands/monitor/monitor.js.map +1 -1
  24. package/dist/src/commands/monitor/notifyGame.js +2 -2
  25. package/dist/src/commands/monitor/notifyGame.js.map +1 -1
  26. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +3 -3
  27. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
  28. package/dist/src/commands/monitor/spawnSaveDatWriter.js +3 -3
  29. package/dist/src/commands/monitor/spawnSaveDatWriter.js.map +1 -1
  30. package/dist/src/commands/publish/publish.js +17 -17
  31. package/dist/src/commands/publish/publish.js.map +1 -1
  32. package/dist/src/configFile.js +3 -3
  33. package/dist/src/configFile.js.map +1 -1
  34. package/dist/src/exec.js +6 -6
  35. package/dist/src/exec.js.map +1 -1
  36. package/dist/src/file.js +10 -10
  37. package/dist/src/file.js.map +1 -1
  38. package/dist/src/main.js +3 -3
  39. package/dist/src/main.js.map +1 -1
  40. package/dist/src/parseArgs.js +0 -5
  41. package/dist/src/parseArgs.js.map +1 -1
  42. package/dist/src/prompt.js +6 -6
  43. package/dist/src/prompt.js.map +1 -1
  44. package/dist/src/{util.js → utils.js} +15 -2
  45. package/dist/src/utils.js.map +1 -0
  46. package/dist/src/validateNodeVersion.js +2 -2
  47. package/dist/src/validateNodeVersion.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/checkForWindowsTerminalBugs.ts +1 -1
  50. package/src/commands/copy/copy.ts +4 -7
  51. package/src/commands/init/checkIfProjectPathExists.ts +1 -1
  52. package/src/commands/init/checkModTargetDirectory.ts +1 -1
  53. package/src/commands/init/createMod.ts +1 -1
  54. package/src/commands/init/getModsDir.ts +1 -1
  55. package/src/commands/init/getProjectPath.ts +1 -1
  56. package/src/commands/init/installVSCodeExtensions.ts +1 -1
  57. package/src/commands/init/promptSaveSlot.ts +1 -1
  58. package/src/commands/monitor/getTSConfigInclude.ts +1 -1
  59. package/src/commands/monitor/monitor.ts +8 -48
  60. package/src/commands/monitor/notifyGame.ts +1 -1
  61. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +1 -1
  62. package/src/commands/monitor/spawnSaveDatWriter.ts +1 -1
  63. package/src/commands/publish/publish.ts +1 -1
  64. package/src/configFile.ts +1 -1
  65. package/src/exec.ts +1 -1
  66. package/src/file.ts +1 -1
  67. package/src/main.ts +1 -1
  68. package/src/parseArgs.ts +0 -5
  69. package/src/prompt.ts +1 -1
  70. package/src/{util.ts → utils.ts} +16 -1
  71. package/src/validateNodeVersion.ts +1 -1
  72. package/dist/src/util.js.map +0 -1
@@ -2,7 +2,7 @@ import chalk from "chalk";
2
2
  import { CWD } from "../../constants";
3
3
  import * as file from "../../file";
4
4
  import { getInputYesNo } from "../../prompt";
5
- import { error } from "../../util";
5
+ import { error } from "../../utils";
6
6
 
7
7
  export async function checkIfProjectPathExists(
8
8
  projectPath: string,
@@ -3,7 +3,7 @@ import path from "path";
3
3
  import { PROJECT_NAME } from "../../constants";
4
4
  import * as file from "../../file";
5
5
  import { getInputYesNo } from "../../prompt";
6
- import { error } from "../../util";
6
+ import { error } from "../../utils";
7
7
 
8
8
  export async function checkModTargetDirectory(
9
9
  modsDirectory: string,
@@ -23,7 +23,7 @@ import { execShell } from "../../exec";
23
23
  import * as file from "../../file";
24
24
  import { getInputString, getInputYesNo } from "../../prompt";
25
25
  import { GitHubCLIHostsYAML } from "../../types/GitHubCLIHostsYAML";
26
- import { error, parseSemVer } from "../../util";
26
+ import { error, parseSemVer } from "../../utils";
27
27
 
28
28
  const REQUIRED_GIT_MAJOR_VERSION = 2;
29
29
  const REQUIRED_GIT_MINOR_VERSION = 30;
@@ -3,7 +3,7 @@ import path from "path";
3
3
  import { HOME_DIR } from "../../constants";
4
4
  import * as file from "../../file";
5
5
  import { getInputString } from "../../prompt";
6
- import { error } from "../../util";
6
+ import { error } from "../../utils";
7
7
 
8
8
  const MODS = "mods";
9
9
 
@@ -2,7 +2,7 @@ import chalk from "chalk";
2
2
  import path from "path";
3
3
  import { CURRENT_DIRECTORY_NAME, CWD } from "../../constants";
4
4
  import { getInputString, getInputYesNo } from "../../prompt";
5
- import { hasWhiteSpace } from "../../util";
5
+ import { hasWhiteSpace } from "../../utils";
6
6
 
7
7
  // From: https://gist.github.com/doctaphred/d01d05291546186941e1b7ddc02034d3
8
8
  const ILLEGAL_CHARACTERS_FOR_WINDOWS_FILENAMES = [
@@ -3,7 +3,7 @@ import * as JSONC from "jsonc-parser";
3
3
  import path from "path";
4
4
  import { execShell } from "../../exec";
5
5
  import * as file from "../../file";
6
- import { error } from "../../util";
6
+ import { error } from "../../utils";
7
7
 
8
8
  export function installVSCodeExtensions(
9
9
  projectPath: string,
@@ -1,5 +1,5 @@
1
1
  import { getInputInt } from "../../prompt";
2
- import { error } from "../../util";
2
+ import { error } from "../../utils";
3
3
 
4
4
  export async function promptSaveSlot(
5
5
  argv: Record<string, unknown>,
@@ -2,7 +2,7 @@ import chalk from "chalk";
2
2
  import * as JSONC from "jsonc-parser";
3
3
  import { TSCONFIG_PATH } from "../../constants";
4
4
  import * as file from "../../file";
5
- import { error } from "../../util";
5
+ import { error } from "../../utils";
6
6
 
7
7
  export function getTSConfigInclude(): string {
8
8
  const tsConfigRaw = file.read(TSCONFIG_PATH);
@@ -1,18 +1,16 @@
1
1
  import chalk from "chalk";
2
- import { ChildProcessWithoutNullStreams, fork, spawn } from "child_process";
2
+ import { fork, spawn } from "child_process";
3
3
  import path from "path";
4
4
  import {
5
- CUSTOM_NODE_JS_STACK_SIZE,
6
5
  CWD,
7
6
  FILE_SYNCED_MESSAGE,
8
7
  MAIN_LUA,
9
8
  MOD_SOURCE_PATH,
10
- PACKAGE_JSON,
11
9
  PROJECT_NAME,
12
10
  } from "../../constants";
13
11
  import * as file from "../../file";
14
12
  import { Config } from "../../types/Config";
15
- import { error, getModTargetDirectoryName } from "../../util";
13
+ import { error, getModTargetDirectoryName, getTSTLArgs } from "../../utils";
16
14
  import { copyWatcherMod } from "./copyWatcherMod";
17
15
  import { getTSConfigInclude } from "./getTSConfigInclude";
18
16
  import * as notifyGame from "./notifyGame";
@@ -53,7 +51,7 @@ export function monitor(argv: Record<string, unknown>, config: Config): void {
53
51
  spawnModDirectorySyncer(config);
54
52
 
55
53
  // Subprocess #3 - tstl --watch (to automatically convert TypeScript to Lua)
56
- spawnTSTLWatcher(argv);
54
+ spawnTSTLWatcher();
57
55
 
58
56
  // Also, start constantly pinging the watcher mod
59
57
  setInterval(() => {
@@ -101,42 +99,12 @@ function spawnModDirectorySyncer(config: Config) {
101
99
  });
102
100
  }
103
101
 
104
- function spawnTSTLWatcher(argv: Record<string, unknown>) {
102
+ function spawnTSTLWatcher() {
105
103
  const processDescription = "tstl";
106
- const crashDebug = argv.crashDebug === true;
107
-
108
- const tstlArgs = ["--watch", "--preserveWatchOutput"];
109
- if (crashDebug) {
110
- tstlArgs.push("--luaPlugins");
111
- tstlArgs.push(
112
- '\'{ "name": "./node_modules/isaacscript/src/plugins/addCrashDebugStatements.ts" }\'',
113
- );
114
- }
115
-
116
- let tstl: ChildProcessWithoutNullStreams;
117
- if (runningFromLocalPath()) {
118
- const tstlPath = path.join(
119
- CWD,
120
- "..",
121
- "isaacscript",
122
- "node_modules",
123
- "typescript-to-lua",
124
- "dist",
125
- "tstl.js",
126
- );
127
- tstl = spawn("node", [tstlPath, ...tstlArgs], {
128
- shell: true,
129
- cwd: CWD,
130
- });
131
- } else {
132
- tstl = spawn(
133
- "npx",
134
- [`--stack-size=${CUSTOM_NODE_JS_STACK_SIZE}`, "tstl", ...tstlArgs],
135
- {
136
- shell: true,
137
- },
138
- );
139
- }
104
+ const tstlArgs = getTSTLArgs(true);
105
+ const tstl = spawn("node", tstlArgs, {
106
+ shell: true,
107
+ });
140
108
 
141
109
  tstl.stdout.on("data", (data: Buffer[]) => {
142
110
  const msg = data.toString().trim();
@@ -173,11 +141,3 @@ function spawnTSTLWatcher(argv: Record<string, unknown>) {
173
141
  error(`Error: ${processDescription} subprocess exited with code: ${code}`);
174
142
  });
175
143
  }
176
-
177
- // Returns whether or not IsaacScript is a local path in "package.json"
178
- // e.g. "isaacscript": "../isaacscript"
179
- function runningFromLocalPath() {
180
- const packageJSONPath = path.join(CWD, PACKAGE_JSON);
181
- const packageJSON = file.read(packageJSONPath);
182
- return packageJSON.includes('"isaacscript": "file:../isaacscript"');
183
- }
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { getTime } from "../../util";
2
+ import { getTime } from "../../utils";
3
3
  import { sendMsgToSaveDatWriter } from "./spawnSaveDatWriter";
4
4
 
5
5
  export function msg(data: string): void {
@@ -3,7 +3,7 @@ import * as JSONC from "jsonc-parser";
3
3
  import path from "path";
4
4
  import { PROJECT_NAME } from "../../../constants";
5
5
  import * as file from "../../../file";
6
- import { ensureAllCases, error } from "../../../util";
6
+ import { ensureAllCases, error } from "../../../utils";
7
7
  import { SaveDatMessage, SaveDatMessageType } from "./types";
8
8
 
9
9
  const MAX_MESSAGES = 100;
@@ -2,7 +2,7 @@ import { ChildProcess, fork } from "child_process";
2
2
  import path from "path";
3
3
  import { WATCHER_MOD_NAME } from "../../constants";
4
4
  import { Config } from "../../types/Config";
5
- import { error } from "../../util";
5
+ import { error } from "../../utils";
6
6
  import { SaveDatMessage } from "./saveDatWriter/types";
7
7
 
8
8
  let saveDatWriter: ChildProcess | null = null;
@@ -15,7 +15,7 @@ import {
15
15
  import { execExe, execShell } from "../../exec";
16
16
  import * as file from "../../file";
17
17
  import { Config } from "../../types/Config";
18
- import { error, getModTargetDirectoryName, parseIntSafe } from "../../util";
18
+ import { error, getModTargetDirectoryName, parseIntSafe } from "../../utils";
19
19
  import { compileAndCopy } from "../copy/copy";
20
20
 
21
21
  const UPDATE_SCRIPT_NAME = "update.sh";
package/src/configFile.ts CHANGED
@@ -6,7 +6,7 @@ import { promptSaveSlot } from "./commands/init/promptSaveSlot";
6
6
  import { CONFIG_FILE_NAME, CONFIG_FILE_PATH, CWD } from "./constants";
7
7
  import * as file from "./file";
8
8
  import { Config } from "./types/Config";
9
- import { error } from "./util";
9
+ import { error } from "./utils";
10
10
 
11
11
  export async function get(argv: Record<string, unknown>): Promise<Config> {
12
12
  const verbose = argv.verbose === true;
package/src/exec.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import chalk from "chalk";
2
2
  import { execSync, spawnSync, SpawnSyncReturns } from "child_process";
3
3
  import { CWD } from "./constants";
4
- import { error } from "./util";
4
+ import { error } from "./utils";
5
5
 
6
6
  export function execExe(path: string, verbose = false, cwd = CWD): string {
7
7
  if (verbose) {
package/src/file.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import chalk from "chalk";
2
2
  import fs from "fs-extra";
3
3
  import path from "path";
4
- import { error } from "./util";
4
+ import { error } from "./utils";
5
5
 
6
6
  export function copy(srcPath: string, dstPath: string, verbose: boolean): void {
7
7
  if (verbose) {
package/src/main.ts CHANGED
@@ -18,7 +18,7 @@ import { parseArgs } from "./parseArgs";
18
18
  import { promptInit } from "./prompt";
19
19
  import { Command, DEFAULT_COMMAND } from "./types/Command";
20
20
  import { Config } from "./types/Config";
21
- import { ensureAllCases, error } from "./util";
21
+ import { ensureAllCases, error } from "./utils";
22
22
  import { validateInIsaacScriptProject } from "./validateInIsaacScriptProject";
23
23
  import { validateNodeVersion } from "./validateNodeVersion";
24
24
  import { validateOS } from "./validateOS";
package/src/parseArgs.ts CHANGED
@@ -20,11 +20,6 @@ export function parseArgs() {
20
20
  choices: [1, 2, 3],
21
21
  description: "The save slot in-game that you use",
22
22
  })
23
- .option("crash-debug", {
24
- alias: "c",
25
- type: "boolean",
26
- description: "Enable crash debugging",
27
- })
28
23
  .option("verbose", {
29
24
  alias: "v",
30
25
  type: "boolean",
package/src/prompt.ts CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  import chalk from "chalk";
6
6
  import prompt from "prompt";
7
- import { error, parseIntSafe } from "./util";
7
+ import { error, parseIntSafe } from "./utils";
8
8
 
9
9
  const VALID_YES_RESPONSES = new Set(["yes", "ye", "y"]);
10
10
  const VALID_NO_RESPONSES = new Set(["no", "n"]);
@@ -1,5 +1,5 @@
1
1
  import moment from "moment";
2
- import { CURRENT_DIRECTORY_NAME } from "./constants";
2
+ import { CURRENT_DIRECTORY_NAME, CUSTOM_NODE_JS_STACK_SIZE } from "./constants";
3
3
  import { Config } from "./types/Config";
4
4
 
5
5
  export const ensureAllCases = (obj: never): never => obj;
@@ -19,6 +19,21 @@ export function getTime(): string {
19
19
  return moment().format("h:mm:ss A"); // e.g. "1:23:45 AM"
20
20
  }
21
21
 
22
+ export function getTSTLArgs(watch: boolean): string[] {
23
+ // We cannot pass the "--stack-size" flag to the "npx" command
24
+ // Thus, we must execute node directly with the following arguments
25
+ const tstlArgs = [
26
+ `--stack-size=${CUSTOM_NODE_JS_STACK_SIZE}`,
27
+ "node_modules/@zamiell/typescript-to-lua/dist/tstl.js",
28
+ ];
29
+
30
+ if (watch) {
31
+ tstlArgs.push("--watch", "--preserveWatchOutput");
32
+ }
33
+
34
+ return tstlArgs;
35
+ }
36
+
22
37
  // From: https://stackoverflow.com/questions/1731190/check-if-a-string-has-white-space
23
38
  export function hasWhiteSpace(s: string): boolean {
24
39
  return /\s/g.test(s);
@@ -1,6 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import { PROJECT_NAME } from "./constants";
3
- import { parseSemVer } from "./util";
3
+ import { parseSemVer } from "./utils";
4
4
 
5
5
  const REQUIRED_NODE_JS_MAJOR_VERSION = 16;
6
6
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2CAAqD;AAG9C,MAAM,cAAc,GAAG,CAAC,GAAU,EAAS,EAAE,CAAC,GAAG,CAAC;AAA5C,QAAA,cAAc,kBAA8B;AAEzD,SAAgB,KAAK,CAAC,GAAG,IAAe;IACtC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAHD,sBAGC;AAED,SAAgB,yBAAyB,CAAC,MAAc;IACtD,OAAO,MAAM,CAAC,4BAA4B,KAAK,SAAS;QACtD,CAAC,CAAC,kCAAsB;QACxB,CAAC,CAAC,MAAM,CAAC,4BAA4B,CAAC;AAC1C,CAAC;AAJD,8DAIC;AAED,SAAgB,OAAO;IACrB,OAAO,IAAA,gBAAM,GAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,oBAAoB;AAC3D,CAA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