isaacscript 3.16.0 → 3.16.1-dev.0

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 (214) hide show
  1. package/dist/checkForWindowsTerminalBugs.js +57 -0
  2. package/{src → dist}/classes/Config.js +1 -6
  3. package/dist/classes/ValidatedConfig.js +1 -0
  4. package/{src → dist}/commands/check/check.js +60 -68
  5. package/dist/commands/check/check.test.js +86 -0
  6. package/dist/commands/copy/copy.js +29 -0
  7. package/dist/commands/init/checkIfProjectPathExists.js +21 -0
  8. package/dist/commands/init/checkModSubdirectory.js +9 -0
  9. package/dist/commands/init/checkModTargetDirectory.js +24 -0
  10. package/dist/commands/init/createProject.js +199 -0
  11. package/dist/commands/init/getAuthorName.js +22 -0
  12. package/dist/commands/init/getModsDir.js +48 -0
  13. package/dist/commands/init/getProjectPath.js +84 -0
  14. package/dist/commands/init/init.js +73 -0
  15. package/dist/commands/init/installVSCodeExtensions.js +27 -0
  16. package/dist/commands/init/promptSaveSlot.js +17 -0
  17. package/{src → dist}/commands/init/promptVSCode.js +5 -10
  18. package/dist/commands/monitor/copyWatcherMod.js +31 -0
  19. package/dist/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +44 -0
  20. package/dist/commands/monitor/monitor.js +154 -0
  21. package/{src → dist}/commands/monitor/notifyGame.js +14 -22
  22. package/{src → dist}/commands/monitor/saveDatWriter/saveDatWriter.js +24 -27
  23. package/dist/commands/monitor/saveDatWriter/types.js +1 -0
  24. package/dist/commands/monitor/spawnModDirectorySyncer.js +31 -0
  25. package/dist/commands/monitor/spawnSaveDatWriter.js +29 -0
  26. package/dist/commands/monitor/spawnTSTLWatcher.js +74 -0
  27. package/dist/commands/monitor/touchWatcherSaveDatFiles.js +15 -0
  28. package/dist/commands/publish/isaacscriptMod.js +90 -0
  29. package/dist/commands/publish/prePublish.js +105 -0
  30. package/dist/commands/publish/publish.js +39 -0
  31. package/dist/commands/publish/validate.js +46 -0
  32. package/dist/common.js +65 -0
  33. package/dist/configFile.js +54 -0
  34. package/dist/constants.js +61 -0
  35. package/dist/customStage.js +298 -0
  36. package/dist/dev.js +10 -0
  37. package/{src/enums → dist/enums/copied}/DoorSlot.js +5 -6
  38. package/dist/enums/copied/DoorSlotFlag.js +35 -0
  39. package/{src/enums → dist/enums/copied}/RoomShape.js +5 -6
  40. package/{src → dist}/exec.js +19 -28
  41. package/dist/git.js +133 -0
  42. package/dist/interfaces/GitHubCLIHostsYAML.js +1 -0
  43. package/dist/interfaces/IsaacScriptTSConfig.js +1 -0
  44. package/dist/interfaces/ShadersXML.js +1 -0
  45. package/dist/interfaces/copied/CustomStageTSConfig.js +4 -0
  46. package/dist/interfaces/copied/JSONRoomsFile.js +4 -0
  47. package/dist/main.js +132 -0
  48. package/dist/objects/copied/doorSlotToDoorSlotFlag.js +16 -0
  49. package/dist/objects/copied/roomShapeToDoorSlotCoordinates.js +112 -0
  50. package/dist/packageManager.js +68 -0
  51. package/{src → dist}/parseArgs.js +36 -15
  52. package/dist/prompt.js +79 -0
  53. package/dist/tsconfig.js +98 -0
  54. package/dist/types/Command.js +4 -0
  55. package/dist/utils.js +8 -0
  56. package/dist/validateInIsaacScriptProject.js +29 -0
  57. package/dist/validateNodeVersion.js +20 -0
  58. package/file-templates/dynamic/.github/workflows/setup/action.yml +21 -0
  59. package/file-templates/dynamic/README.mod.md +4 -3
  60. package/file-templates/dynamic/_gitignore +0 -2
  61. package/file-templates/dynamic/package.mod.json +8 -0
  62. package/file-templates/dynamic/package.ts.json +5 -1
  63. package/file-templates/{dynamic → static}/.github/workflows/ci.yml +10 -38
  64. package/file-templates/static/scripts/tsconfig.json +28 -0
  65. package/file-templates/static-mod/.vscode/settings.json +1 -1
  66. package/file-templates/static-mod/{_cspell.json → _cspell.jsonc} +2 -2
  67. package/file-templates/static-mod/_eslintrc.cjs +1 -1
  68. package/file-templates/static-mod/prettier.config.mjs +6 -1
  69. package/file-templates/static-mod/scripts/lint.ts +36 -0
  70. package/file-templates/static-mod/tsconfig.json +5 -5
  71. package/file-templates/static-ts/.vscode/settings.json +1 -1
  72. package/file-templates/static-ts/{_cspell.json → _cspell.jsonc} +5 -5
  73. package/file-templates/static-ts/_eslintrc.cjs +1 -1
  74. package/file-templates/static-ts/knip.jsonc +6 -0
  75. package/file-templates/static-ts/prettier.config.mjs +6 -1
  76. package/file-templates/static-ts/scripts/lint.ts +30 -0
  77. package/file-templates/static-ts/tsconfig.json +3 -3
  78. package/package.json +27 -9
  79. package/plugins/addCrashDebugStatements.cjs +56 -0
  80. package/plugins/addCrashDebugStatements.ts +39 -0
  81. package/{src/plugins/addIsaacScriptCommentHeader.js → plugins/addIsaacScriptCommentHeader.cjs} +1 -1
  82. package/plugins/addIsaacScriptCommentHeader.ts +42 -0
  83. package/{src/plugins/addIsaacScriptCommentHeaderCommon.js → plugins/addIsaacScriptCommentHeaderCommon.cjs} +6 -4
  84. package/plugins/addIsaacScriptCommentHeaderCommon.ts +59 -0
  85. package/{src/plugins/noExtendedEnums.js → plugins/noExtendedEnums.cjs} +25 -4
  86. package/plugins/noExtendedEnums.ts +83 -0
  87. package/plugins/tsconfig.json +28 -0
  88. package/schemas/tsconfig-isaacscript-section-schema.json +1 -0
  89. package/file-templates/static/nuke.sh +0 -53
  90. package/file-templates/static/update.sh +0 -26
  91. package/file-templates/static-mod/build.sh +0 -22
  92. package/file-templates/static-mod/lint.sh +0 -43
  93. package/file-templates/static-mod/publish.sh +0 -10
  94. package/file-templates/static-mod/run.sh +0 -10
  95. package/file-templates/static-ts/build.sh +0 -53
  96. package/file-templates/static-ts/lint.sh +0 -35
  97. package/file-templates/static-ts/publish.sh +0 -10
  98. package/file-templates/static-ts/run.sh +0 -42
  99. package/src/checkForWindowsTerminalBugs.js +0 -71
  100. package/src/checkForWindowsTerminalBugs.js.map +0 -1
  101. package/src/classes/Config.js.map +0 -1
  102. package/src/classes/ValidatedConfig.js +0 -3
  103. package/src/classes/ValidatedConfig.js.map +0 -1
  104. package/src/commands/check/check.js.map +0 -1
  105. package/src/commands/check/check.test.js +0 -87
  106. package/src/commands/check/check.test.js.map +0 -1
  107. package/src/commands/copy/copy.js +0 -38
  108. package/src/commands/copy/copy.js.map +0 -1
  109. package/src/commands/init/checkIfProjectPathExists.js +0 -28
  110. package/src/commands/init/checkIfProjectPathExists.js.map +0 -1
  111. package/src/commands/init/checkModSubdirectory.js +0 -16
  112. package/src/commands/init/checkModSubdirectory.js.map +0 -1
  113. package/src/commands/init/checkModTargetDirectory.js +0 -31
  114. package/src/commands/init/checkModTargetDirectory.js.map +0 -1
  115. package/src/commands/init/createProject.js +0 -220
  116. package/src/commands/init/createProject.js.map +0 -1
  117. package/src/commands/init/getAuthorName.js +0 -27
  118. package/src/commands/init/getAuthorName.js.map +0 -1
  119. package/src/commands/init/getModsDir.js +0 -58
  120. package/src/commands/init/getModsDir.js.map +0 -1
  121. package/src/commands/init/getProjectPath.js +0 -89
  122. package/src/commands/init/getProjectPath.js.map +0 -1
  123. package/src/commands/init/init.js +0 -78
  124. package/src/commands/init/init.js.map +0 -1
  125. package/src/commands/init/installVSCodeExtensions.js +0 -35
  126. package/src/commands/init/installVSCodeExtensions.js.map +0 -1
  127. package/src/commands/init/promptSaveSlot.js +0 -22
  128. package/src/commands/init/promptSaveSlot.js.map +0 -1
  129. package/src/commands/init/promptVSCode.js.map +0 -1
  130. package/src/commands/monitor/copyWatcherMod.js +0 -39
  131. package/src/commands/monitor/copyWatcherMod.js.map +0 -1
  132. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +0 -47
  133. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +0 -1
  134. package/src/commands/monitor/monitor.js +0 -263
  135. package/src/commands/monitor/monitor.js.map +0 -1
  136. package/src/commands/monitor/notifyGame.js.map +0 -1
  137. package/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +0 -1
  138. package/src/commands/monitor/saveDatWriter/types.js +0 -3
  139. package/src/commands/monitor/saveDatWriter/types.js.map +0 -1
  140. package/src/commands/monitor/spawnSaveDatWriter.js +0 -35
  141. package/src/commands/monitor/spawnSaveDatWriter.js.map +0 -1
  142. package/src/commands/monitor/touchWatcherSaveDatFiles.js +0 -21
  143. package/src/commands/monitor/touchWatcherSaveDatFiles.js.map +0 -1
  144. package/src/commands/publish/isaacscriptMod.js +0 -97
  145. package/src/commands/publish/isaacscriptMod.js.map +0 -1
  146. package/src/commands/publish/prePublish.js +0 -120
  147. package/src/commands/publish/prePublish.js.map +0 -1
  148. package/src/commands/publish/publish.js +0 -42
  149. package/src/commands/publish/publish.js.map +0 -1
  150. package/src/commands/publish/validate.js +0 -58
  151. package/src/commands/publish/validate.js.map +0 -1
  152. package/src/common.js +0 -69
  153. package/src/common.js.map +0 -1
  154. package/src/configFile.js +0 -64
  155. package/src/configFile.js.map +0 -1
  156. package/src/constants.js +0 -67
  157. package/src/constants.js.map +0 -1
  158. package/src/customStage.js +0 -304
  159. package/src/customStage.js.map +0 -1
  160. package/src/dev.js +0 -19
  161. package/src/dev.js.map +0 -1
  162. package/src/enums/DoorSlot.js.map +0 -1
  163. package/src/enums/DoorSlotFlag.js +0 -37
  164. package/src/enums/DoorSlotFlag.js.map +0 -1
  165. package/src/enums/PackageManager.js +0 -10
  166. package/src/enums/PackageManager.js.map +0 -1
  167. package/src/enums/RoomShape.js.map +0 -1
  168. package/src/exec.js.map +0 -1
  169. package/src/file.js +0 -247
  170. package/src/file.js.map +0 -1
  171. package/src/git.js +0 -154
  172. package/src/git.js.map +0 -1
  173. package/src/interfaces/GitHubCLIHostsYAML.js +0 -3
  174. package/src/interfaces/GitHubCLIHostsYAML.js.map +0 -1
  175. package/src/interfaces/IsaacScriptTSConfig.js +0 -3
  176. package/src/interfaces/IsaacScriptTSConfig.js.map +0 -1
  177. package/src/interfaces/ShadersXML.js +0 -3
  178. package/src/interfaces/ShadersXML.js.map +0 -1
  179. package/src/interfaces/copied/CustomStageTSConfig.js +0 -4
  180. package/src/interfaces/copied/CustomStageTSConfig.js.map +0 -1
  181. package/src/interfaces/copied/JSONRoomsFile.js +0 -4
  182. package/src/interfaces/copied/JSONRoomsFile.js.map +0 -1
  183. package/src/isaacScriptCommonTS.js +0 -233
  184. package/src/isaacScriptCommonTS.js.map +0 -1
  185. package/src/json.js +0 -42
  186. package/src/json.js.map +0 -1
  187. package/src/main.js +0 -127
  188. package/src/main.js.map +0 -1
  189. package/src/objects/doorSlotToDoorSlotFlag.js +0 -17
  190. package/src/objects/doorSlotToDoorSlotFlag.js.map +0 -1
  191. package/src/objects/roomShapeDoorToSlotCoordinates.js +0 -115
  192. package/src/objects/roomShapeDoorToSlotCoordinates.js.map +0 -1
  193. package/src/packageManager.js +0 -153
  194. package/src/packageManager.js.map +0 -1
  195. package/src/parseArgs.js.map +0 -1
  196. package/src/plugins/addCrashDebugStatements.js +0 -32
  197. package/src/plugins/addCrashDebugStatements.js.map +0 -1
  198. package/src/plugins/addIsaacScriptCommentHeader.js.map +0 -1
  199. package/src/plugins/addIsaacScriptCommentHeaderCommon.js.map +0 -1
  200. package/src/plugins/noExtendedEnums.js.map +0 -1
  201. package/src/prompt.js +0 -87
  202. package/src/prompt.js.map +0 -1
  203. package/src/tsconfig.js +0 -103
  204. package/src/tsconfig.js.map +0 -1
  205. package/src/types/Command.js +0 -9
  206. package/src/types/Command.js.map +0 -1
  207. package/src/utils.js +0 -15
  208. package/src/utils.js.map +0 -1
  209. package/src/validateInIsaacScriptProject.js +0 -36
  210. package/src/validateInIsaacScriptProject.js.map +0 -1
  211. package/src/validateNodeVersion.js +0 -29
  212. package/src/validateNodeVersion.js.map +0 -1
  213. package/src/version.js +0 -20
  214. package/src/version.js.map +0 -1
package/dist/dev.js ADDED
@@ -0,0 +1,10 @@
1
+ import { fatalError, isDirectory } from "isaacscript-common-node";
2
+ import path from "node:path";
3
+ export function getAndValidateIsaacScriptMonorepoDirectory(projectPath) {
4
+ const isaacScriptMonorepoDirectory = path.join(projectPath, "..", "isaacscript");
5
+ if (!isDirectory(isaacScriptMonorepoDirectory)) {
6
+ console.error(`Failed to find the IsaacScript repository at: ${isaacScriptMonorepoDirectory}`);
7
+ fatalError("In order to link a development version of IsaacScript common, you must place the repositories side by side. (If you do not already have the IsaacScript repository cloned, then you need to fork the repo and then clone your fork.)");
8
+ }
9
+ return isaacScriptMonorepoDirectory;
10
+ }
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DoorSlot = void 0;
4
- var DoorSlot;
1
+ /// THIS FILE IS AUTOMATICALLY GENERATED BY THE "build.ts" SCRIPT.
2
+ /// IT IS COPIED FROM THE "isaac-typescript-definitions" package.
3
+ /// DO NOT EDIT THIS FILE!
4
+ export var DoorSlot;
5
5
  (function (DoorSlot) {
6
6
  DoorSlot[DoorSlot["NO_DOOR_SLOT"] = -1] = "NO_DOOR_SLOT";
7
7
  /** In a normal room, the left door. In a 2x2 room, the uppermost door on the left side. */
@@ -20,5 +20,4 @@ var DoorSlot;
20
20
  DoorSlot[DoorSlot["RIGHT_1"] = 6] = "RIGHT_1";
21
21
  /** In a 2x2 room, the rightmost door on the bottom side. */
22
22
  DoorSlot[DoorSlot["DOWN_1"] = 7] = "DOWN_1";
23
- })(DoorSlot || (exports.DoorSlot = DoorSlot = {}));
24
- //# sourceMappingURL=DoorSlot.js.map
23
+ })(DoorSlot || (DoorSlot = {}));
@@ -0,0 +1,35 @@
1
+ /// THIS FILE IS AUTOMATICALLY GENERATED BY THE "build.ts" SCRIPT.
2
+ /// IT IS COPIED FROM THE "isaac-typescript-definitions" package.
3
+ /// DO NOT EDIT THIS FILE!
4
+ /* eslint-disable no-bitwise */
5
+ import { DoorSlot } from "./DoorSlot.js";
6
+ /**
7
+ * For `GridEntityType.DOOR` (16).
8
+ *
9
+ * This is represented as an object instead of an enum due to limitations with TypeScript enums. (We
10
+ * want this type to be a child of the `BitFlag` type.)
11
+ *
12
+ * @enum
13
+ * @notExported
14
+ * @rename DoorSlotFlag
15
+ */
16
+ const DoorSlotFlagInternal = {
17
+ /** 1 << 0 (1) */
18
+ LEFT_0: 1 << DoorSlot.LEFT_0,
19
+ /** 1 << 1 (2) */
20
+ UP_0: 1 << DoorSlot.UP_0,
21
+ /** 1 << 2 (4) */
22
+ RIGHT_0: 1 << DoorSlot.RIGHT_0,
23
+ /** 1 << 3 (8) */
24
+ DOWN_0: 1 << DoorSlot.DOWN_0,
25
+ /** 1 << 4 (16) */
26
+ LEFT_1: 1 << DoorSlot.LEFT_1,
27
+ /** 1 << 5 (32) */
28
+ UP_1: 1 << DoorSlot.UP_1,
29
+ /** 1 << 6 (64) */
30
+ RIGHT_1: 1 << DoorSlot.RIGHT_1,
31
+ /** 1 << 7 (128) */
32
+ DOWN_1: 1 << DoorSlot.DOWN_1,
33
+ };
34
+ export const DoorSlotFlag = DoorSlotFlagInternal;
35
+ export const DoorSlotFlagZero = 0;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoomShape = void 0;
4
- var RoomShape;
1
+ /// THIS FILE IS AUTOMATICALLY GENERATED BY THE "build.ts" SCRIPT.
2
+ /// IT IS COPIED FROM THE "isaac-typescript-definitions" package.
3
+ /// DO NOT EDIT THIS FILE!
4
+ export var RoomShape;
5
5
  (function (RoomShape) {
6
6
  /**
7
7
  * A "normal" room.
@@ -43,5 +43,4 @@ var RoomShape;
43
43
  RoomShape[RoomShape["LBL"] = 11] = "LBL";
44
44
  /** Looks like a "Г" with a gap in the bottom-right-hand corner. */
45
45
  RoomShape[RoomShape["LBR"] = 12] = "LBR";
46
- })(RoomShape || (exports.RoomShape = RoomShape = {}));
47
- //# sourceMappingURL=RoomShape.js.map
46
+ })(RoomShape || (RoomShape = {}));
@@ -1,52 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.execShell = exports.execShellString = exports.execPowershell = exports.execExe = void 0;
4
- const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
- const node_child_process_1 = require("node:child_process");
7
- const constants_js_1 = require("./constants.js");
8
- const isaacScriptCommonTS_js_1 = require("./isaacScriptCommonTS.js");
9
- function execExe(path, args, verbose, cwd = constants_js_1.CWD) {
1
+ import chalk from "chalk";
2
+ import { fatalError } from "isaacscript-common-node";
3
+ import { execFileSync, execSync, spawnSync } from "node:child_process";
4
+ import { CWD } from "./constants.js";
5
+ export function execExe(path, args, verbose, cwd = CWD) {
10
6
  if (verbose) {
11
7
  console.log(`Executing binary: ${path}`);
12
8
  }
13
9
  let stdout;
14
10
  try {
15
- const buffer = (0, node_child_process_1.execFileSync)(path, args, {
11
+ const buffer = execFileSync(path, args, {
16
12
  cwd,
17
13
  });
18
14
  stdout = buffer.toString().trim();
19
15
  }
20
16
  catch (error) {
21
- (0, isaacScriptCommonTS_js_1.fatalError)(`Failed to run "${chalk_1.default.green(path)}":`, error);
17
+ fatalError(`Failed to run "${chalk.green(path)}":`, error);
22
18
  }
23
19
  if (verbose) {
24
20
  console.log(`Executed binary: ${path}`);
25
21
  }
26
22
  return stdout;
27
23
  }
28
- exports.execExe = execExe;
29
- function execPowershell(command, verbose = false, cwd = constants_js_1.CWD) {
24
+ export function execPowershell(command, verbose = false, cwd = CWD) {
30
25
  if (verbose) {
31
26
  console.log(`Executing PowerShell command: ${command}`);
32
27
  }
33
28
  let stdout;
34
29
  try {
35
- const buffer = (0, node_child_process_1.execSync)(command, {
30
+ const buffer = execSync(command, {
36
31
  shell: "powershell.exe",
37
32
  cwd,
38
33
  });
39
34
  stdout = buffer.toString().trim();
40
35
  }
41
36
  catch (error) {
42
- (0, isaacScriptCommonTS_js_1.fatalError)(`Failed to run PowerShell command "${chalk_1.default.green(command)}":`, error);
37
+ fatalError(`Failed to run PowerShell command "${chalk.green(command)}":`, error);
43
38
  }
44
39
  if (verbose) {
45
40
  console.log(`Executed PowerShell command: ${command}`);
46
41
  }
47
42
  return stdout;
48
43
  }
49
- exports.execPowershell = execPowershell;
50
44
  /**
51
45
  * Same as `execShell`, but accepts the command as a string instead of an array of arguments.
52
46
  *
@@ -55,15 +49,14 @@ exports.execPowershell = execPowershell;
55
49
  * @param allowFailure Default is false.
56
50
  * @param cwd Default is CWD.
57
51
  */
58
- function execShellString(commandString, verbose = false, allowFailure = false, cwd = constants_js_1.CWD) {
52
+ export function execShellString(commandString, verbose = false, allowFailure = false, cwd = CWD) {
59
53
  const args = commandString.split(" ");
60
54
  const command = args.shift();
61
55
  if (command === undefined) {
62
- (0, isaacScriptCommonTS_js_1.fatalError)(`execShellString failed to parse the command of: ${commandString}`);
56
+ fatalError(`execShellString failed to parse the command of: ${commandString}`);
63
57
  }
64
58
  return execShell(command, args, verbose, allowFailure, cwd);
65
59
  }
66
- exports.execShellString = execShellString;
67
60
  /**
68
61
  * Returns a tuple of exit status and stdout. The stdout is trimmed for convenience.
69
62
  *
@@ -73,15 +66,15 @@ exports.execShellString = execShellString;
73
66
  * @param allowFailure Default is false.
74
67
  * @param cwd Default is CWD.
75
68
  */
76
- function execShell(command, args = [], verbose = false, allowFailure = false, cwd = constants_js_1.CWD) {
69
+ export function execShell(command, args = [], verbose = false, allowFailure = false, cwd = CWD) {
77
70
  // On Windows, "spawnSync()" will not account for spaces in arguments. Thus, wrap everything in a
78
71
  // double quote. This will cause arguments that naturally have double quotes to fail.
79
72
  if (command.includes("''") || command.includes('"')) {
80
- (0, isaacScriptCommonTS_js_1.fatalError)("execShell cannot execute commands with single quotes or double quotes in the command.");
73
+ fatalError("execShell cannot execute commands with single quotes or double quotes in the command.");
81
74
  }
82
75
  const argsHasDoubleQuotes = args.some((arg) => arg.includes('"'));
83
76
  if (argsHasDoubleQuotes) {
84
- (0, isaacScriptCommonTS_js_1.fatalError)("execShell cannot execute commands with double quotes in the arguments.");
77
+ fatalError("execShell cannot execute commands with double quotes in the arguments.");
85
78
  }
86
79
  const quotedArgs = args.map((arg) => `"${arg}"`);
87
80
  const commandDescription = `${command} ${quotedArgs.join(" ")}`.trim();
@@ -90,32 +83,30 @@ function execShell(command, args = [], verbose = false, allowFailure = false, cw
90
83
  }
91
84
  let spawnSyncReturns;
92
85
  try {
93
- spawnSyncReturns = (0, node_child_process_1.spawnSync)(command, quotedArgs, {
86
+ spawnSyncReturns = spawnSync(command, quotedArgs, {
94
87
  shell: true,
95
88
  cwd,
96
89
  });
97
90
  }
98
91
  catch (error) {
99
- (0, isaacScriptCommonTS_js_1.fatalError)(`Failed to run the "${chalk_1.default.green(commandDescription)}" command:`, error);
92
+ fatalError(`Failed to run the "${chalk.green(commandDescription)}" command:`, error);
100
93
  }
101
94
  if (verbose) {
102
95
  console.log(`Executed command: ${commandDescription}`);
103
96
  }
104
97
  const exitStatus = spawnSyncReturns.status;
105
98
  if (exitStatus === null) {
106
- (0, isaacScriptCommonTS_js_1.fatalError)(`Failed to get the return status of command: ${commandDescription}`);
99
+ fatalError(`Failed to get the return status of command: ${commandDescription}`);
107
100
  }
108
101
  const stdout = spawnSyncReturns.output.join("\n").trim();
109
102
  if (exitStatus !== 0) {
110
103
  if (allowFailure) {
111
104
  return { exitStatus, stdout };
112
105
  }
113
- console.error(`Failed to run the "${chalk_1.default.green(commandDescription)}" command with an exit code of ${exitStatus}.`);
106
+ console.error(`Failed to run the "${chalk.green(commandDescription)}" command with an exit code of ${exitStatus}.`);
114
107
  console.error("The output was as follows:");
115
108
  console.error(stdout);
116
109
  process.exit(1);
117
110
  }
118
111
  return { exitStatus, stdout };
119
112
  }
120
- exports.execShell = execShell;
121
- //# sourceMappingURL=exec.js.map
package/dist/git.js ADDED
@@ -0,0 +1,133 @@
1
+ import chalk from "chalk";
2
+ import commandExists from "command-exists";
3
+ import { getPackageJSONVersion, isFile, readFile, } from "isaacscript-common-node";
4
+ import path from "node:path";
5
+ import yaml from "yaml";
6
+ import { HOME_DIR, PROJECT_NAME, REPO_ROOT } from "./constants.js";
7
+ import { execShell, execShellString } from "./exec.js";
8
+ import { getInputString, getInputYesNo } from "./prompt.js";
9
+ export async function promptGitHubRepoOrGitRemoteURL(projectName, noGit, yes, dev, verbose) {
10
+ if (noGit || dev) {
11
+ return undefined;
12
+ }
13
+ // Hard-code certain project names as never causing a Git repository to be initialized.
14
+ if (projectName.startsWith("test") || projectName === "foo") {
15
+ return undefined;
16
+ }
17
+ // We do not need to prompt the user if they do not have Git installed.
18
+ if (!commandExists.sync("git")) {
19
+ console.log('Git does not seem to be installed. (The "git" command is not in the path.) Skipping Git-related things.');
20
+ return undefined;
21
+ }
22
+ const gitHubUsername = getGitHubUsername();
23
+ if (gitHubUsername !== undefined) {
24
+ const { exitStatus } = execShell("gh", ["repo", "view", projectName], verbose, true);
25
+ const gitHubRepoExists = exitStatus === 0;
26
+ const url = `https://github.com/${gitHubUsername}/${projectName}`;
27
+ if (gitHubRepoExists) {
28
+ console.log(`Detected an existing GitHub repository at: ${chalk.green(url)}`);
29
+ const guessedRemoteURL = getGitRemoteURL(projectName, gitHubUsername);
30
+ if (yes) {
31
+ console.log(`Using a Git remote URL of: ${chalk.green(guessedRemoteURL)}`);
32
+ return guessedRemoteURL;
33
+ }
34
+ const shouldUseGuessedURL = await getInputYesNo(`Do you want to use a Git remote URL of: ${chalk.green(guessedRemoteURL)}`);
35
+ if (shouldUseGuessedURL) {
36
+ return guessedRemoteURL;
37
+ }
38
+ // Assume that since they do not want to connect this project to the existing GitHub
39
+ // repository, they do not want to initialize a remote Git URL at all.
40
+ return undefined;
41
+ }
42
+ if (yes) {
43
+ execShell("gh", ["repo", "create", projectName, "--public"]);
44
+ console.log(`Created a new GitHub repository at: ${chalk.green(url)}`);
45
+ return getGitRemoteURL(projectName, gitHubUsername);
46
+ }
47
+ const createNewGitHubRepo = await getInputYesNo(`Would you like to create a new GitHub repository at: ${chalk.green(url)}`);
48
+ if (createNewGitHubRepo) {
49
+ execShell("gh", ["repo", "create", projectName, "--public"]);
50
+ console.log("Successfully created a new GitHub repository.");
51
+ return getGitRemoteURL(projectName, gitHubUsername);
52
+ }
53
+ // Assume that since they do not want to create a new GitHub repository, they do not want to
54
+ // initialize a remote Git URL at all.
55
+ return undefined;
56
+ }
57
+ const gitRemoteURL = await getInputString(`Paste in the remote Git URL for your project.
58
+ For example, if you have an SSH key, it would be something like:
59
+ ${chalk.green("git@github.com:Alice/green-candle.git")}
60
+ If you don't have an SSH key, it would be something like:
61
+ ${chalk.green("https://github.com/Alice/green-candle.git")}
62
+ If you don't want to initialize a Git repository for this project, press enter to skip.
63
+ `);
64
+ return gitRemoteURL === "" ? undefined : gitRemoteURL;
65
+ }
66
+ export function getGitHubUsername() {
67
+ // If the GitHub CLI is installed, we can derive the user's GitHub username.
68
+ if (!commandExists.sync("gh")) {
69
+ return undefined;
70
+ }
71
+ const githubCLIHostsPath = getGithubCLIHostsPath();
72
+ if (githubCLIHostsPath === undefined) {
73
+ return undefined;
74
+ }
75
+ if (!isFile(githubCLIHostsPath)) {
76
+ return undefined;
77
+ }
78
+ const configYAMLRaw = readFile(githubCLIHostsPath);
79
+ const configYAML = yaml.parse(configYAMLRaw);
80
+ const githubCom = configYAML["github.com"];
81
+ if (githubCom === undefined) {
82
+ return undefined;
83
+ }
84
+ const { user } = githubCom;
85
+ if (user === undefined || user === "") {
86
+ return undefined;
87
+ }
88
+ return user;
89
+ }
90
+ function getGithubCLIHostsPath() {
91
+ if (process.platform === "win32") {
92
+ const appData = process.env["APPDATA"];
93
+ if (appData === undefined || appData === "") {
94
+ return undefined;
95
+ }
96
+ return path.join(appData, "GitHub CLI", "hosts.yml");
97
+ }
98
+ // The location is the same on both macOS and Linux.
99
+ return path.join(HOME_DIR, ".config", "gh", "hosts.yml");
100
+ }
101
+ function getGitRemoteURL(projectName, gitHubUsername) {
102
+ return `git@github.com:${gitHubUsername}/${projectName}.git`;
103
+ }
104
+ export function initGitRepository(projectPath, gitRemoteURL, verbose) {
105
+ if (!commandExists.sync("git")) {
106
+ return;
107
+ }
108
+ if (gitRemoteURL === undefined) {
109
+ return;
110
+ }
111
+ execShellString("git init --initial-branch=main", verbose, false, projectPath);
112
+ if (isGitNameAndEmailConfigured(verbose)) {
113
+ execShellString("git add --all", verbose, false, projectPath);
114
+ const isaacScriptCLIVersion = getPackageJSONVersion(REPO_ROOT);
115
+ const commitMessage = `chore: add files from ${PROJECT_NAME} ${isaacScriptCLIVersion} template`;
116
+ execShell("git", ["commit", "--message", commitMessage], verbose, false, projectPath);
117
+ }
118
+ execShell("git", ["remote", "add", "origin", gitRemoteURL], verbose, false, projectPath);
119
+ }
120
+ function isGitNameAndEmailConfigured(verbose) {
121
+ const nameExitStatus = execShellString("git config --global user.name", verbose, true).exitStatus;
122
+ const emailExitStatus = execShellString("git config --global user.email", verbose, true).exitStatus;
123
+ return nameExitStatus === 0 && emailExitStatus === 0;
124
+ }
125
+ export function gitCommitAllAndPush(message, verbose) {
126
+ execShellString("git add --all", verbose);
127
+ execShell("git", ["commit", "--message", message], verbose);
128
+ execShellString("git push", verbose);
129
+ console.log(`Committed and pushed to the git repository with a message of: ${message}`);
130
+ }
131
+ export function getReleaseGitCommitMessage(version) {
132
+ return `chore: release ${version}`;
133
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /// THIS FILE IS AUTOMATICALLY GENERATED BY THE "build.ts" SCRIPT.
2
+ /// IT IS COPIED FROM THE "isaacscript-common" package.
3
+ /// DO NOT EDIT THIS FILE!
4
+ export {};
@@ -0,0 +1,4 @@
1
+ /// THIS FILE IS AUTOMATICALLY GENERATED BY THE "build.ts" SCRIPT.
2
+ /// IT IS COPIED FROM THE "isaacscript-common" package.
3
+ /// DO NOT EDIT THIS FILE!
4
+ export {};
package/dist/main.js ADDED
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ import chalk from "chalk";
3
+ import figlet from "figlet";
4
+ import { fatalError, getPackageJSONVersion, getPackageManagerInstallCommand, nukeDependencies, updatePackageJSON, } from "isaacscript-common-node";
5
+ import sourceMapSupport from "source-map-support";
6
+ import { checkForWindowsTerminalBugs } from "./checkForWindowsTerminalBugs.js";
7
+ import { Config } from "./classes/Config.js";
8
+ import { check } from "./commands/check/check.js";
9
+ import { copy } from "./commands/copy/copy.js";
10
+ import { init } from "./commands/init/init.js";
11
+ import { monitor } from "./commands/monitor/monitor.js";
12
+ import { publish } from "./commands/publish/publish.js";
13
+ import { getConfigFromFile } from "./configFile.js";
14
+ import { CWD, PROJECT_NAME, REPO_ROOT } from "./constants.js";
15
+ import { execShellString } from "./exec.js";
16
+ import { getPackageManagerUsedForExistingProject } from "./packageManager.js";
17
+ import { parseArgs } from "./parseArgs.js";
18
+ import { promptInit } from "./prompt.js";
19
+ import { DEFAULT_COMMAND, isIsaacScriptModCommand } from "./types/Command.js";
20
+ import { validateInIsaacScriptProject } from "./validateInIsaacScriptProject.js";
21
+ import { validateNodeVersion } from "./validateNodeVersion.js";
22
+ await main();
23
+ async function main() {
24
+ sourceMapSupport.install();
25
+ promptInit();
26
+ const args = parseArgs();
27
+ const command = getCommandFromArgs(args);
28
+ validateNodeVersion();
29
+ printBanner(command);
30
+ // Pre-flight checks
31
+ await checkForWindowsTerminalBugs();
32
+ await handleCommands(command, args);
33
+ if (command !== "monitor") {
34
+ process.exit(0);
35
+ }
36
+ }
37
+ function getCommandFromArgs(args) {
38
+ const positionalArgs = args._;
39
+ const firstPositionArg = positionalArgs[0];
40
+ return firstPositionArg === undefined || firstPositionArg === ""
41
+ ? DEFAULT_COMMAND
42
+ : firstPositionArg;
43
+ }
44
+ function printBanner(command) {
45
+ // Skip displaying the banner for specific commands.
46
+ if (command.startsWith("check")) {
47
+ return;
48
+ }
49
+ const banner = figlet.textSync(PROJECT_NAME);
50
+ console.log(chalk.green(banner));
51
+ const isaacScriptCLIVersion = getPackageJSONVersion(REPO_ROOT);
52
+ const versionString = `v${isaacScriptCLIVersion}`;
53
+ const bannerLines = banner.split("\n");
54
+ const firstBannerLine = bannerLines[0];
55
+ if (firstBannerLine === undefined) {
56
+ fatalError(firstBannerLine, "Failed to get the first line of the banner text.");
57
+ }
58
+ const bannerHorizontalLength = firstBannerLine.length;
59
+ const leftPaddingAmount = Math.floor((bannerHorizontalLength + versionString.length) / 2);
60
+ const versionLine = versionString.padStart(leftPaddingAmount);
61
+ console.log(`${versionLine}\n`);
62
+ }
63
+ async function handleCommands(command, args) {
64
+ const skipProjectChecks = args.skipProjectChecks === true;
65
+ const verbose = args.verbose === true;
66
+ let config = new Config();
67
+ if (command !== "init" &&
68
+ command !== "check" &&
69
+ isIsaacScriptModCommand(command)) {
70
+ if (!skipProjectChecks) {
71
+ validateInIsaacScriptProject();
72
+ }
73
+ const shouldDisplayOutput = !command.startsWith("check");
74
+ ensureDepsAreInstalled(args, shouldDisplayOutput, verbose);
75
+ config = await getConfigFromFile(args, false);
76
+ }
77
+ switch (command) {
78
+ case "monitor": {
79
+ await monitor(args, config);
80
+ break;
81
+ }
82
+ case "init": {
83
+ await init(args, false);
84
+ break;
85
+ }
86
+ case "init-ts": {
87
+ await init(args, true);
88
+ break;
89
+ }
90
+ case "copy": {
91
+ await copy(args, config);
92
+ break;
93
+ }
94
+ case "publish": {
95
+ await publish(args, config, false);
96
+ break;
97
+ }
98
+ case "publish-ts": {
99
+ await publish(args, config, true);
100
+ break;
101
+ }
102
+ case "check": {
103
+ check(args, false);
104
+ break;
105
+ }
106
+ case "check-ts": {
107
+ check(args, true);
108
+ break;
109
+ }
110
+ case "update": {
111
+ const hasNewDependencies = await updatePackageJSON(CWD);
112
+ const msg = hasNewDependencies
113
+ ? "Successfully installed new Node.js dependencies."
114
+ : "There were no new Node.js dependency updates.";
115
+ console.log(msg);
116
+ break;
117
+ }
118
+ case "nuke": {
119
+ nukeDependencies(CWD);
120
+ console.log("Successfully reinstalled Node.js dependencies.");
121
+ break;
122
+ }
123
+ }
124
+ }
125
+ function ensureDepsAreInstalled(args, shouldDisplayOutput, verbose) {
126
+ const packageManager = getPackageManagerUsedForExistingProject(args);
127
+ const command = getPackageManagerInstallCommand(packageManager);
128
+ if (shouldDisplayOutput) {
129
+ console.log(`Running "${command}" to ensure that the project's dependencies are installed correctly.`);
130
+ }
131
+ execShellString(command, verbose);
132
+ }
@@ -0,0 +1,16 @@
1
+ /// THIS FILE IS AUTOMATICALLY GENERATED BY THE "build.ts" SCRIPT.
2
+ /// IT IS COPIED FROM THE "isaacscript-common" package.
3
+ /// DO NOT EDIT THIS FILE!
4
+ import { DoorSlot } from "../../enums/copied/DoorSlot.js";
5
+ import { DoorSlotFlag, DoorSlotFlagZero, } from "../../enums/copied/DoorSlotFlag.js";
6
+ export const DOOR_SLOT_TO_DOOR_SLOT_FLAG = {
7
+ [DoorSlot.NO_DOOR_SLOT]: DoorSlotFlagZero,
8
+ [DoorSlot.LEFT_0]: DoorSlotFlag.LEFT_0,
9
+ [DoorSlot.UP_0]: DoorSlotFlag.UP_0,
10
+ [DoorSlot.RIGHT_0]: DoorSlotFlag.RIGHT_0,
11
+ [DoorSlot.DOWN_0]: DoorSlotFlag.DOWN_0,
12
+ [DoorSlot.LEFT_1]: DoorSlotFlag.LEFT_1,
13
+ [DoorSlot.UP_1]: DoorSlotFlag.UP_1,
14
+ [DoorSlot.RIGHT_1]: DoorSlotFlag.RIGHT_1,
15
+ [DoorSlot.DOWN_1]: DoorSlotFlag.DOWN_1, // 7
16
+ };
@@ -0,0 +1,112 @@
1
+ /// THIS FILE IS AUTOMATICALLY GENERATED BY THE "build.ts" SCRIPT.
2
+ /// IT IS COPIED FROM THE "isaacscript-common" package.
3
+ /// DO NOT EDIT THIS FILE!
4
+ import { DoorSlot } from "../../enums/copied/DoorSlot.js";
5
+ import { RoomShape } from "../../enums/copied/RoomShape.js";
6
+ /**
7
+ * The coordinates correspond to the x and y values that are present in a room's XML file.
8
+ *
9
+ * e.g. `<door exists="False" x="-1" y="3" />`
10
+ */
11
+ export const ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES = {
12
+ // 1
13
+ [RoomShape.SHAPE_1x1]: {
14
+ [DoorSlot.LEFT_0]: [-1, 3],
15
+ [DoorSlot.UP_0]: [6, -1],
16
+ [DoorSlot.RIGHT_0]: [13, 3],
17
+ [DoorSlot.DOWN_0]: [6, 7], // 3
18
+ },
19
+ // 2
20
+ [RoomShape.IH]: {
21
+ [DoorSlot.LEFT_0]: [-1, 3],
22
+ [DoorSlot.RIGHT_0]: [13, 3], // 2
23
+ },
24
+ // 3
25
+ [RoomShape.IV]: {
26
+ [DoorSlot.UP_0]: [6, -1],
27
+ [DoorSlot.DOWN_0]: [6, 7], // 3
28
+ },
29
+ // 4
30
+ [RoomShape.SHAPE_1x2]: {
31
+ [DoorSlot.LEFT_0]: [-1, 3],
32
+ [DoorSlot.UP_0]: [6, -1],
33
+ [DoorSlot.RIGHT_0]: [13, 3],
34
+ [DoorSlot.DOWN_0]: [6, 14],
35
+ [DoorSlot.LEFT_1]: [-1, 10],
36
+ [DoorSlot.RIGHT_1]: [13, 10], // 6
37
+ },
38
+ // 5
39
+ [RoomShape.IIV]: {
40
+ [DoorSlot.UP_0]: [6, -1],
41
+ [DoorSlot.DOWN_0]: [6, 14], // 3
42
+ },
43
+ // 6
44
+ [RoomShape.SHAPE_2x1]: {
45
+ [DoorSlot.LEFT_0]: [-1, 3],
46
+ [DoorSlot.UP_0]: [6, -1],
47
+ [DoorSlot.RIGHT_0]: [26, 3],
48
+ [DoorSlot.DOWN_0]: [6, 7],
49
+ [DoorSlot.UP_1]: [19, -1],
50
+ [DoorSlot.DOWN_1]: [19, 7], // 7
51
+ },
52
+ // 7
53
+ [RoomShape.IIH]: {
54
+ [DoorSlot.LEFT_0]: [-1, 3],
55
+ [DoorSlot.RIGHT_0]: [26, 3], // 2
56
+ },
57
+ // 8
58
+ [RoomShape.SHAPE_2x2]: {
59
+ [DoorSlot.LEFT_0]: [-1, 3],
60
+ [DoorSlot.UP_0]: [6, -1],
61
+ [DoorSlot.RIGHT_0]: [26, 3],
62
+ [DoorSlot.DOWN_0]: [6, 14],
63
+ [DoorSlot.LEFT_1]: [-1, 10],
64
+ [DoorSlot.UP_1]: [19, -1],
65
+ [DoorSlot.RIGHT_1]: [26, 10],
66
+ [DoorSlot.DOWN_1]: [19, 14], // 7
67
+ },
68
+ // 9
69
+ [RoomShape.LTL]: {
70
+ [DoorSlot.LEFT_0]: [12, 3],
71
+ [DoorSlot.UP_0]: [6, 6],
72
+ [DoorSlot.RIGHT_0]: [26, 3],
73
+ [DoorSlot.DOWN_0]: [6, 14],
74
+ [DoorSlot.LEFT_1]: [-1, 10],
75
+ [DoorSlot.UP_1]: [19, -1],
76
+ [DoorSlot.RIGHT_1]: [26, 10],
77
+ [DoorSlot.DOWN_1]: [19, 14], // 7
78
+ },
79
+ // 10
80
+ [RoomShape.LTR]: {
81
+ [DoorSlot.LEFT_0]: [-1, 3],
82
+ [DoorSlot.UP_0]: [6, -1],
83
+ [DoorSlot.RIGHT_0]: [13, 3],
84
+ [DoorSlot.DOWN_0]: [6, 14],
85
+ [DoorSlot.LEFT_1]: [-1, 10],
86
+ [DoorSlot.UP_1]: [19, 6],
87
+ [DoorSlot.RIGHT_1]: [26, 10],
88
+ [DoorSlot.DOWN_1]: [19, 14], // 7
89
+ },
90
+ // 11
91
+ [RoomShape.LBL]: {
92
+ [DoorSlot.LEFT_0]: [-1, 3],
93
+ [DoorSlot.UP_0]: [6, -1],
94
+ [DoorSlot.RIGHT_0]: [26, 3],
95
+ [DoorSlot.DOWN_0]: [6, 7],
96
+ [DoorSlot.LEFT_1]: [12, 10],
97
+ [DoorSlot.UP_1]: [19, -1],
98
+ [DoorSlot.RIGHT_1]: [26, 10],
99
+ [DoorSlot.DOWN_1]: [19, 14], // 7
100
+ },
101
+ // 12
102
+ [RoomShape.LBR]: {
103
+ [DoorSlot.LEFT_0]: [-1, 3],
104
+ [DoorSlot.UP_0]: [6, -1],
105
+ [DoorSlot.RIGHT_0]: [26, 3],
106
+ [DoorSlot.DOWN_0]: [6, 14],
107
+ [DoorSlot.LEFT_1]: [-1, 10],
108
+ [DoorSlot.UP_1]: [19, -1],
109
+ [DoorSlot.RIGHT_1]: [13, 10],
110
+ [DoorSlot.DOWN_1]: [19, 7], // 7
111
+ },
112
+ };