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
@@ -0,0 +1,57 @@
1
+ import chalk from "chalk";
2
+ import { appendFile, isFile, readFile } from "isaacscript-common-node";
3
+ import path from "node:path";
4
+ import { HOME_DIR, PROJECT_NAME } from "./constants.js";
5
+ import { getInputYesNo } from "./prompt.js";
6
+ const BASH_PROFILE_PATH = path.join(HOME_DIR, ".bash_profile");
7
+ /**
8
+ * By default, Git Bash for Windows uses MINGW64. This will not work correctly with the prompt
9
+ * library. Try to detect this and warn the end-user.
10
+ */
11
+ export async function checkForWindowsTerminalBugs() {
12
+ if (process.platform !== "win32") {
13
+ return;
14
+ }
15
+ if (process.env["SHELL"] !== "C:\\Program Files\\Git\\usr\\bin\\bash.exe") {
16
+ return;
17
+ }
18
+ await checkForWindowsBugColor();
19
+ }
20
+ async function checkForWindowsBugColor() {
21
+ if (process.env["FORCE_COLOR"] === "true") {
22
+ return;
23
+ }
24
+ console.error(chalk.red(`Error: It looks like you are using Git Bash for Windows (MINGW64) without the "${chalk.green("FORCE_COLOR")}" environment variable.`));
25
+ console.error("This is necessary in order for colors to work properly in the terminal.");
26
+ const shouldFixColors = await getInputYesNo("Do you want me to fix this for you?");
27
+ if (!shouldFixColors) {
28
+ return;
29
+ }
30
+ applyFixesToBashProfile();
31
+ }
32
+ function applyFixesToBashProfile() {
33
+ // Check to see if the Bash profile has data.
34
+ const bashProfileContents = isFile(BASH_PROFILE_PATH)
35
+ ? readFile(BASH_PROFILE_PATH)
36
+ : "";
37
+ const appendText = getBashProfileAppendText(bashProfileContents);
38
+ appendFile(BASH_PROFILE_PATH, appendText);
39
+ console.log(`The terminal fixes have been added to: ${chalk.green(BASH_PROFILE_PATH)}`, chalk.red("Please close and re-open your terminal, then run this program again."));
40
+ process.exit(0);
41
+ }
42
+ function getBashProfileAppendText(bashProfileContents) {
43
+ let newText = "";
44
+ if (bashProfileContents !== "" && !bashProfileContents.endsWith("\n")) {
45
+ // If the Bash profile exists and has data, it should end in a newline. Add an extra newline if
46
+ // this is not the case.
47
+ newText += "\n";
48
+ }
49
+ if (bashProfileContents !== "") {
50
+ // If the Bash profile exists and has data, add an extra newline between the existing stuff and
51
+ // the new lines added by us.
52
+ newText += "\n";
53
+ }
54
+ newText += `# Terminal fixes added by ${PROJECT_NAME}\n`;
55
+ newText += "export FORCE_COLOR=true\n";
56
+ return newText;
57
+ }
@@ -1,11 +1,8 @@
1
- "use strict";
2
1
  // - Note that all mandatory properties must be explicitly validated in `configFile.ts`.
3
2
  // - The types are explicitly annotated to work around a bug in `ts-json-schema-generator`:
4
3
  // https://github.com/vega/ts-json-schema-generator/issues/1531
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Config = void 0;
7
4
  /** This is the format for the "isaacscript.json" file. */
8
- class Config {
5
+ export class Config {
9
6
  // Marked as public to disable `knip` warnings.
10
7
  /** @public */
11
8
  $schema = "https://raw.githubusercontent.com/IsaacScript/isaacscript/main/packages/isaacscript-cli/schemas/isaacscript-schema.json";
@@ -41,5 +38,3 @@ class Config {
41
38
  }
42
39
  }
43
40
  }
44
- exports.Config = Config;
45
- //# sourceMappingURL=Config.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -1,16 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTruncatedText = exports.check = void 0;
4
- const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
- const klaw_sync_1 = tslib_1.__importDefault(require("klaw-sync"));
7
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
- const constants_js_1 = require("../../constants.js");
9
- const PackageManager_js_1 = require("../../enums/PackageManager.js");
10
- const exec_js_1 = require("../../exec.js");
11
- const file_js_1 = require("../../file.js");
12
- const isaacScriptCommonTS_js_1 = require("../../isaacScriptCommonTS.js");
13
- const packageManager_js_1 = require("../../packageManager.js");
1
+ import chalk from "chalk";
2
+ import { PACKAGE_MANAGER_LOCK_FILE_NAMES, PackageManager, deleteFileOrDirectory, fatalError, isDirectory, isFile, readFile, writeFile, } from "isaacscript-common-node";
3
+ import { ReadonlySet, getEnumValues, trimPrefix } from "isaacscript-common-ts";
4
+ import klawSync from "klaw-sync";
5
+ import path from "node:path";
6
+ import { ACTION_YML, ACTION_YML_TEMPLATE_PATH, CWD, TEMPLATES_DIR, TEMPLATES_DYNAMIC_DIR, TEMPLATES_STATIC_DIR, YARNRC_TEMPLATE_PATH, YARNRC_YML, } from "../../constants.js";
7
+ import { execShell } from "../../exec.js";
8
+ import { getPackageManagerUsedForExistingProject } from "../../packageManager.js";
14
9
  const URL_PREFIX = "https://raw.githubusercontent.com/IsaacScript/isaacscript/main/packages/isaacscript-cli/file-templates";
15
10
  const MARKER_CUSTOMIZATION_START = "@template-customization-start";
16
11
  const MARKER_CUSTOMIZATION_END = "@template-customization-end";
@@ -21,23 +16,23 @@ const PACKAGE_MANAGER_STRINGS = [
21
16
  "PACKAGE_MANAGER_NAME",
22
17
  "PACKAGE_MANAGER_INSTALL_COMMAND",
23
18
  "PACKAGE_MANAGER_LOCK_FILE_NAME",
24
- ...(0, isaacScriptCommonTS_js_1.getEnumValues)(PackageManager_js_1.PackageManager),
25
- ...(0, packageManager_js_1.getAllPackageManagerLockFileNames)(),
19
+ ...getEnumValues(PackageManager),
20
+ ...PACKAGE_MANAGER_LOCK_FILE_NAMES,
26
21
  ];
27
- function check(args, typeScript) {
22
+ export function check(args, typeScript) {
28
23
  const ignore = args.ignore ?? "";
29
24
  const verbose = args.verbose === true;
30
- const packageManager = (0, packageManager_js_1.getPackageManagerUsedForExistingProject)(args, verbose);
25
+ const packageManager = getPackageManagerUsedForExistingProject(args);
31
26
  let oneOrMoreErrors = false;
32
27
  const ignoreFileNames = ignore.split(",");
33
- const ignoreFileNamesSet = new isaacScriptCommonTS_js_1.ReadonlySet(ignoreFileNames);
28
+ const ignoreFileNamesSet = new ReadonlySet(ignoreFileNames);
34
29
  // First, check the static files that are shared between TypeScript projects and IsaacScript mods.
35
- if (checkTemplateDirectory(constants_js_1.TEMPLATES_STATIC_DIR, ignoreFileNamesSet, verbose)) {
30
+ if (checkTemplateDirectory(TEMPLATES_STATIC_DIR, ignoreFileNamesSet, verbose)) {
36
31
  oneOrMoreErrors = true;
37
32
  }
38
33
  // Second, check the files that are specific to either a TypeScript project or an IsaacScript mod.
39
34
  const staticDirSuffix = typeScript ? "ts" : "mod";
40
- const staticDirPath = node_path_1.default.join(constants_js_1.TEMPLATES_DIR, `static-${staticDirSuffix}`);
35
+ const staticDirPath = path.join(TEMPLATES_DIR, `static-${staticDirSuffix}`);
41
36
  if (checkTemplateDirectory(staticDirPath, ignoreFileNamesSet, verbose)) {
42
37
  oneOrMoreErrors = true;
43
38
  }
@@ -46,39 +41,38 @@ function check(args, typeScript) {
46
41
  oneOrMoreErrors = true;
47
42
  }
48
43
  if (oneOrMoreErrors) {
49
- (0, isaacScriptCommonTS_js_1.fatalError)("The check command failed.");
44
+ fatalError("The check command failed.");
50
45
  }
51
46
  }
52
- exports.check = check;
53
47
  function checkTemplateDirectory(templateDirectory, ignoreFileNamesSet, verbose) {
54
48
  let oneOrMoreErrors = false;
55
- for (const klawItem of (0, klaw_sync_1.default)(templateDirectory)) {
49
+ for (const klawItem of klawSync(templateDirectory)) {
56
50
  const templateFilePath = klawItem.path;
57
- if ((0, file_js_1.isDir)(templateFilePath, verbose)) {
51
+ if (isDirectory(templateFilePath)) {
58
52
  continue;
59
53
  }
60
- const originalFileName = node_path_1.default.basename(templateFilePath);
54
+ const originalFileName = path.basename(templateFilePath);
61
55
  if (originalFileName === "main.ts") {
62
56
  continue;
63
57
  }
64
- const relativeTemplateFilePath = node_path_1.default.relative(templateDirectory, templateFilePath);
65
- const templateFileName = node_path_1.default.basename(relativeTemplateFilePath);
66
- let projectFilePath = node_path_1.default.join(constants_js_1.CWD, relativeTemplateFilePath);
58
+ const relativeTemplateFilePath = path.relative(templateDirectory, templateFilePath);
59
+ const templateFileName = path.basename(relativeTemplateFilePath);
60
+ let projectFilePath = path.join(CWD, relativeTemplateFilePath);
67
61
  switch (templateFileName) {
68
62
  case "_eslintrc.cjs": {
69
- projectFilePath = node_path_1.default.join(projectFilePath, "..", ".eslintrc.cjs");
63
+ projectFilePath = path.join(projectFilePath, "..", ".eslintrc.cjs");
70
64
  break;
71
65
  }
72
- case "_cspell.json": {
73
- projectFilePath = node_path_1.default.join(projectFilePath, "..", "cspell.json");
66
+ case "_cspell.jsonc": {
67
+ projectFilePath = path.join(projectFilePath, "..", "cspell.jsonc");
74
68
  break;
75
69
  }
76
70
  case "_gitattributes": {
77
- projectFilePath = node_path_1.default.join(projectFilePath, "..", ".gitattributes");
71
+ projectFilePath = path.join(projectFilePath, "..", ".gitattributes");
78
72
  break;
79
73
  }
80
74
  }
81
- const projectFileName = node_path_1.default.basename(projectFilePath);
75
+ const projectFileName = path.basename(projectFilePath);
82
76
  if (ignoreFileNamesSet.has(projectFileName)) {
83
77
  continue;
84
78
  }
@@ -90,19 +84,19 @@ function checkTemplateDirectory(templateDirectory, ignoreFileNamesSet, verbose)
90
84
  }
91
85
  function checkIndividualFiles(ignoreFileNamesSet, packageManager, verbose) {
92
86
  let oneOrMoreErrors = false;
93
- if (!ignoreFileNamesSet.has(constants_js_1.CI_YML)) {
94
- const templateFilePath = constants_js_1.CI_YML_TEMPLATE_PATH;
95
- const relativeTemplateFilePath = node_path_1.default.relative(constants_js_1.TEMPLATES_DYNAMIC_DIR, templateFilePath);
96
- const projectFilePath = node_path_1.default.join(constants_js_1.CWD, relativeTemplateFilePath);
87
+ if (!ignoreFileNamesSet.has(ACTION_YML)) {
88
+ const templateFilePath = ACTION_YML_TEMPLATE_PATH;
89
+ const relativeTemplateFilePath = path.relative(TEMPLATES_DYNAMIC_DIR, templateFilePath);
90
+ const projectFilePath = path.join(CWD, relativeTemplateFilePath);
97
91
  if (!compareTextFiles(projectFilePath, templateFilePath, verbose)) {
98
92
  oneOrMoreErrors = true;
99
93
  }
100
94
  }
101
- if (packageManager === PackageManager_js_1.PackageManager.yarn &&
102
- !ignoreFileNamesSet.has(constants_js_1.YARNRC_YML)) {
103
- const templateFilePath = constants_js_1.YARNRC_TEMPLATE_PATH;
104
- const relativeTemplateFilePath = node_path_1.default.relative(constants_js_1.TEMPLATES_DYNAMIC_DIR, templateFilePath);
105
- const projectFilePath = node_path_1.default.join(constants_js_1.CWD, relativeTemplateFilePath);
95
+ if (packageManager === PackageManager.yarn &&
96
+ !ignoreFileNamesSet.has(YARNRC_YML)) {
97
+ const templateFilePath = YARNRC_TEMPLATE_PATH;
98
+ const relativeTemplateFilePath = path.relative(TEMPLATES_DYNAMIC_DIR, templateFilePath);
99
+ const projectFilePath = path.join(CWD, relativeTemplateFilePath);
106
100
  if (!compareTextFiles(projectFilePath, templateFilePath, verbose)) {
107
101
  oneOrMoreErrors = true;
108
102
  }
@@ -111,21 +105,21 @@ function checkIndividualFiles(ignoreFileNamesSet, packageManager, verbose) {
111
105
  }
112
106
  /** @returns Whether the project file is valid in reference to the template file. */
113
107
  function compareTextFiles(projectFilePath, templateFilePath, verbose) {
114
- if (!(0, file_js_1.fileExists)(projectFilePath, verbose)) {
108
+ if (!isFile(projectFilePath)) {
115
109
  console.log(`Failed to find the following file: ${projectFilePath}`);
116
110
  printTemplateLocation(templateFilePath);
117
111
  return false;
118
112
  }
119
- const projectFileObject = getTruncatedFileText(projectFilePath, new Set(), new Set(), verbose);
120
- const templateFileObject = getTruncatedFileText(templateFilePath, projectFileObject.ignoreLines, projectFileObject.linesBeforeIgnore, verbose);
113
+ const projectFileObject = getTruncatedFileText(projectFilePath, new Set(), new Set());
114
+ const templateFileObject = getTruncatedFileText(templateFilePath, projectFileObject.ignoreLines, projectFileObject.linesBeforeIgnore);
121
115
  if (projectFileObject.text === templateFileObject.text) {
122
116
  return true;
123
117
  }
124
- console.log(`The contents of the following file do not match: ${chalk_1.default.red(projectFilePath)}`);
118
+ console.log(`The contents of the following file do not match: ${chalk.red(projectFilePath)}`);
125
119
  printTemplateLocation(templateFilePath);
126
120
  if (verbose) {
127
- const originalTemplateFile = (0, file_js_1.readFile)(templateFilePath, verbose);
128
- const originalProjectFile = (0, file_js_1.readFile)(projectFilePath, verbose);
121
+ const originalTemplateFile = readFile(templateFilePath);
122
+ const originalProjectFile = readFile(projectFilePath);
129
123
  console.log("--- Original template file: ---\n");
130
124
  console.log(originalTemplateFile);
131
125
  console.log();
@@ -139,19 +133,19 @@ function compareTextFiles(projectFilePath, templateFilePath, verbose) {
139
133
  console.log(projectFileObject.text);
140
134
  console.log();
141
135
  }
142
- const tempProjectFilePath = node_path_1.default.join(constants_js_1.CWD, "tempProjectFile.txt");
143
- const tempTemplateFilePath = node_path_1.default.join(constants_js_1.CWD, "tempTemplateFile.txt");
144
- (0, file_js_1.writeFile)(tempProjectFilePath, projectFileObject.text, verbose);
145
- (0, file_js_1.writeFile)(tempTemplateFilePath, templateFileObject.text, verbose);
146
- const { stdout } = (0, exec_js_1.execShell)("diff", [tempProjectFilePath, tempTemplateFilePath, "--ignore-blank-lines"], verbose, true);
136
+ const tempProjectFilePath = path.join(CWD, "tempProjectFile.txt");
137
+ const tempTemplateFilePath = path.join(CWD, "tempTemplateFile.txt");
138
+ writeFile(tempProjectFilePath, projectFileObject.text);
139
+ writeFile(tempTemplateFilePath, templateFileObject.text);
140
+ const { stdout } = execShell("diff", [tempProjectFilePath, tempTemplateFilePath, "--ignore-blank-lines"], verbose, true);
147
141
  console.log(`${stdout}\n`);
148
- (0, file_js_1.deleteFileOrDirectory)(tempProjectFilePath, verbose);
149
- (0, file_js_1.deleteFileOrDirectory)(tempTemplateFilePath, verbose);
142
+ deleteFileOrDirectory(tempProjectFilePath);
143
+ deleteFileOrDirectory(tempTemplateFilePath);
150
144
  return false;
151
145
  }
152
- function getTruncatedFileText(filePath, ignoreLines, linesBeforeIgnore, verbose) {
153
- const fileName = node_path_1.default.basename(filePath);
154
- const fileContents = (0, file_js_1.readFile)(filePath, verbose);
146
+ function getTruncatedFileText(filePath, ignoreLines, linesBeforeIgnore) {
147
+ const fileName = path.basename(filePath);
148
+ const fileContents = readFile(filePath);
155
149
  return getTruncatedText(fileName, fileContents, ignoreLines, linesBeforeIgnore);
156
150
  }
157
151
  /**
@@ -163,7 +157,7 @@ function getTruncatedFileText(filePath, ignoreLines, linesBeforeIgnore, verbose)
163
157
  * markers (and other specific hard-coded exclusions), as well as an array of lines that
164
158
  * had a "ignore-next-line" marker below them.
165
159
  */
166
- function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
160
+ export function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
167
161
  const lines = text.split("\n");
168
162
  const newLines = [];
169
163
  const newIgnoreLines = new Set();
@@ -212,7 +206,7 @@ function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
212
206
  continue;
213
207
  }
214
208
  if (isIgnoring) {
215
- const baseLine = (0, isaacScriptCommonTS_js_1.trimPrefix)(line.trim(), "// ");
209
+ const baseLine = trimPrefix(line.trim(), "// ");
216
210
  newIgnoreLines.add(baseLine);
217
211
  continue;
218
212
  }
@@ -220,7 +214,7 @@ function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
220
214
  // Specific file checks
221
215
  // --------------------
222
216
  // End-users can have different ignored words.
223
- if (fileName === "cspell.json" || fileName === "_cspell.json") {
217
+ if (fileName === "cspell.jsonc" || fileName === "_cspell.jsonc") {
224
218
  if (line.match(/"words": \[.*]/) !== null) {
225
219
  continue;
226
220
  }
@@ -233,12 +227,12 @@ function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
233
227
  continue;
234
228
  }
235
229
  }
236
- if (fileName === "ci.yml") {
230
+ if (fileName === "ci.yml" || fileName === "action.yml") {
237
231
  // End-users can have different package managers.
238
232
  if (hasPackageManagerString(line)) {
239
233
  continue;
240
234
  }
241
- // Ignore comments, since end-users are expected to delete the explanation.
235
+ // Ignore comments, since end-users are expected to delete the explanations.
242
236
  if (line.match(/^\s*#/) !== null) {
243
237
  continue;
244
238
  }
@@ -258,17 +252,15 @@ function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
258
252
  linesBeforeIgnore: newLinesBeforeIgnore,
259
253
  };
260
254
  }
261
- exports.getTruncatedText = getTruncatedText;
262
255
  function printTemplateLocation(templateFilePath) {
263
- const unixPath = templateFilePath.split(node_path_1.default.sep).join(node_path_1.default.posix.sep);
256
+ const unixPath = templateFilePath.split(path.sep).join(path.posix.sep);
264
257
  const match = unixPath.match(/.+\/file-templates\/(?<urlSuffix>.+)/);
265
258
  if (match === null || match.groups === undefined) {
266
- (0, isaacScriptCommonTS_js_1.fatalError)(`Failed to parse the template file path: ${templateFilePath}`);
259
+ fatalError(`Failed to parse the template file path: ${templateFilePath}`);
267
260
  }
268
261
  const { urlSuffix } = match.groups;
269
- console.log(`You can find the template at: ${chalk_1.default.green(`${URL_PREFIX}/${urlSuffix}`)}\n`);
262
+ console.log(`You can find the template at: ${chalk.green(`${URL_PREFIX}/${urlSuffix}`)}\n`);
270
263
  }
271
264
  function hasPackageManagerString(line) {
272
265
  return PACKAGE_MANAGER_STRINGS.some((string) => line.includes(string));
273
266
  }
274
- //# sourceMappingURL=check.js.map
@@ -0,0 +1,86 @@
1
+ import { strictEqual } from "node:assert";
2
+ import test from "node:test";
3
+ import { getTruncatedText } from "./check.js";
4
+ test("no markers", () => {
5
+ const templateText = `
6
+ line 1
7
+ line 2
8
+ line 3
9
+ `.trim();
10
+ const { text } = getTruncatedText("test", templateText, new Set(), new Set());
11
+ strictEqual(text, templateText);
12
+ });
13
+ test("customization marker", () => {
14
+ const templateText = `
15
+ line 1
16
+ @template-customization-start
17
+ line 2
18
+ @template-customization-end
19
+ line 3
20
+ `.trim();
21
+ const expectedTemplateText = `
22
+ line 1
23
+ line 3
24
+ `.trim();
25
+ const { text } = getTruncatedText("test", templateText, new Set(), new Set());
26
+ strictEqual(text, expectedTemplateText);
27
+ });
28
+ test("ignore block marker part 1", () => {
29
+ const templateText = `
30
+ line 1
31
+ @template-ignore-block-start
32
+ // line 2
33
+ @template-ignore-block-end
34
+ line 3
35
+ `.trim();
36
+ const parsedTemplateText = `
37
+ line 1
38
+ line 3
39
+ `.trim();
40
+ const { text, ignoreLines } = getTruncatedText("test", templateText, new Set(), new Set());
41
+ strictEqual(text, parsedTemplateText);
42
+ strictEqual(ignoreLines.size, 1);
43
+ strictEqual([...ignoreLines][0], "line 2");
44
+ });
45
+ test("ignore block marker part 2", () => {
46
+ const templateText = `
47
+ line 1
48
+ line 2
49
+ line 3
50
+ `.trim();
51
+ const expectedTemplateText = `
52
+ line 1
53
+ line 3
54
+ `.trim();
55
+ const { text } = getTruncatedText("test", templateText, new Set(["line 2"]), new Set());
56
+ strictEqual(text, expectedTemplateText);
57
+ });
58
+ test("ignore next line part 1", () => {
59
+ const templateText = `
60
+ line 1
61
+ @template-ignore-next-line
62
+ line 2
63
+ line 3
64
+ `.trim();
65
+ const expectedTemplateText = `
66
+ line 1
67
+ line 3
68
+ `.trim();
69
+ const { text, linesBeforeIgnore } = getTruncatedText("test", templateText, new Set(), new Set());
70
+ strictEqual(linesBeforeIgnore.size, 1);
71
+ strictEqual([...linesBeforeIgnore][0], "line 1");
72
+ strictEqual(text, expectedTemplateText);
73
+ });
74
+ test("ignore next line part 2", () => {
75
+ const templateText = `
76
+ line 1
77
+ line 2
78
+ line 3
79
+ `.trim();
80
+ const expectedTemplateText = `
81
+ line 1
82
+ line 3
83
+ `.trim();
84
+ const { text } = getTruncatedText("test", templateText, new Set(), new Set(["line 1"]));
85
+ strictEqual(text, expectedTemplateText);
86
+ });
@@ -0,0 +1,29 @@
1
+ import { copyFileOrDirectory, deleteFileOrDirectory, getPackageManagerExecCommand, } from "isaacscript-common-node";
2
+ import path from "node:path";
3
+ import { MOD_SOURCE_PATH } from "../../constants.js";
4
+ import { prepareCustomStages } from "../../customStage.js";
5
+ import { execShellString } from "../../exec.js";
6
+ import { getPackageManagerUsedForExistingProject } from "../../packageManager.js";
7
+ import { getModTargetDirectoryName } from "../../utils.js";
8
+ export async function copy(args, config) {
9
+ const verbose = args.verbose === true;
10
+ const packageManager = getPackageManagerUsedForExistingProject(args);
11
+ const modTargetDirectoryName = getModTargetDirectoryName(config);
12
+ const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
13
+ await compileAndCopy(MOD_SOURCE_PATH, modTargetPath, packageManager, verbose);
14
+ }
15
+ export async function compileAndCopy(modSourcePath, modTargetPath, packageManager, verbose) {
16
+ await prepareCustomStages(packageManager, verbose);
17
+ compile(packageManager, verbose);
18
+ copyMod(modSourcePath, modTargetPath);
19
+ }
20
+ function compile(packageManager, verbose) {
21
+ const command = getPackageManagerExecCommand(packageManager);
22
+ execShellString(`${command} tstl`, verbose);
23
+ console.log("Mod compiled successfully.");
24
+ }
25
+ function copyMod(modSourcePath, modTargetPath) {
26
+ deleteFileOrDirectory(modTargetPath);
27
+ copyFileOrDirectory(modSourcePath, modTargetPath);
28
+ console.log("Mod copied successfully.");
29
+ }
@@ -0,0 +1,21 @@
1
+ import chalk from "chalk";
2
+ import { deleteFileOrDirectory, fatalError, fileOrDirectoryExists, isDirectory, } from "isaacscript-common-node";
3
+ import { CWD } from "../../constants.js";
4
+ import { getInputYesNo } from "../../prompt.js";
5
+ export async function checkIfProjectPathExists(projectPath, yes) {
6
+ if (projectPath === CWD || !fileOrDirectoryExists(projectPath)) {
7
+ return;
8
+ }
9
+ const fileType = isDirectory(projectPath) ? "directory" : "file";
10
+ if (yes) {
11
+ deleteFileOrDirectory(projectPath);
12
+ console.log(`Deleted ${fileType}: ${chalk.green(projectPath)}`);
13
+ return;
14
+ }
15
+ console.log(`A ${fileType} already exists with a name of: ${chalk.green(projectPath)}`);
16
+ const shouldDelete = await getInputYesNo("Do you want me to delete it?");
17
+ if (!shouldDelete) {
18
+ fatalError("Ok then. Goodbye.");
19
+ }
20
+ deleteFileOrDirectory(projectPath);
21
+ }
@@ -0,0 +1,9 @@
1
+ import chalk from "chalk";
2
+ import { fatalError, isSubdirectoryOf } from "isaacscript-common-node";
3
+ import { CWD } from "../../constants.js";
4
+ export function checkModSubdirectory(projectPath, modsDirectory) {
5
+ if (isSubdirectoryOf(CWD, modsDirectory)) {
6
+ console.error(`Error: The project directory of "${chalk.green(projectPath)}" is a subdirectory of "${chalk.green(modsDirectory)}".`);
7
+ fatalError('You are supposed to have your project folder somewhere else on the system than the Isaac mods directory. (This is because we don\'t want to upload the ".git" folder or the TypeScript files to the Steam Workshop.) Exiting.');
8
+ }
9
+ }
@@ -0,0 +1,24 @@
1
+ import chalk from "chalk";
2
+ import { deleteFileOrDirectory, fatalError, fileOrDirectoryExists, isDirectory, } from "isaacscript-common-node";
3
+ import path from "node:path";
4
+ import { PROJECT_NAME } from "../../constants.js";
5
+ import { getInputYesNo } from "../../prompt.js";
6
+ export async function checkModTargetDirectory(modsDirectory, projectName, yes) {
7
+ const modTargetPath = path.join(modsDirectory, projectName);
8
+ if (!fileOrDirectoryExists(modTargetPath)) {
9
+ return;
10
+ }
11
+ const fileType = isDirectory(modTargetPath) ? "directory" : "file";
12
+ if (yes) {
13
+ deleteFileOrDirectory(modTargetPath);
14
+ console.log(`Deleted ${fileType}: ${chalk.green(modTargetPath)}`);
15
+ return;
16
+ }
17
+ console.log(`A ${fileType} already exists at at the mod path of: ${chalk.green(modTargetPath)}`);
18
+ console.log(`${PROJECT_NAME} will need to sync your project folder with this directory.`);
19
+ const shouldDelete = await getInputYesNo("Do you want me to delete it?");
20
+ if (!shouldDelete) {
21
+ fatalError("Ok then. Goodbye.");
22
+ }
23
+ deleteFileOrDirectory(modTargetPath);
24
+ }