isaacscript 2.0.11 → 2.0.14-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 (137) hide show
  1. package/README.md +8 -4
  2. package/package.json +2 -53
  3. package/src/checkForWindowsTerminalBugs.d.ts +5 -0
  4. package/src/checkForWindowsTerminalBugs.js +80 -0
  5. package/src/checkForWindowsTerminalBugs.js.map +1 -0
  6. package/src/commands/copy/copy.d.ts +3 -0
  7. package/src/commands/copy/copy.js +33 -0
  8. package/src/commands/copy/copy.js.map +1 -0
  9. package/src/commands/init/checkIfProjectPathExists.d.ts +1 -0
  10. package/src/commands/init/checkIfProjectPathExists.js +30 -0
  11. package/src/commands/init/checkIfProjectPathExists.js.map +1 -0
  12. package/src/commands/init/checkModSubdirectory.d.ts +1 -0
  13. package/src/commands/init/checkModSubdirectory.js +16 -0
  14. package/src/commands/init/checkModSubdirectory.js.map +1 -0
  15. package/src/commands/init/checkModTargetDirectory.d.ts +1 -0
  16. package/src/commands/init/checkModTargetDirectory.js +33 -0
  17. package/src/commands/init/checkModTargetDirectory.js.map +1 -0
  18. package/src/commands/init/createMod.d.ts +1 -0
  19. package/{dist/src → src}/commands/init/createMod.js +137 -162
  20. package/src/commands/init/createMod.js.map +1 -0
  21. package/src/commands/init/getModsDir.d.ts +1 -0
  22. package/src/commands/init/getModsDir.js +58 -0
  23. package/src/commands/init/getModsDir.js.map +1 -0
  24. package/src/commands/init/getProjectPath.d.ts +1 -0
  25. package/src/commands/init/getProjectPath.js +93 -0
  26. package/src/commands/init/getProjectPath.js.map +1 -0
  27. package/src/commands/init/git.d.ts +4 -0
  28. package/{dist/src → src}/commands/init/git.js +152 -175
  29. package/src/commands/init/git.js.map +1 -0
  30. package/src/commands/init/init.d.ts +1 -0
  31. package/src/commands/init/init.js +70 -0
  32. package/src/commands/init/init.js.map +1 -0
  33. package/src/commands/init/installVSCodeExtensions.d.ts +1 -0
  34. package/src/commands/init/installVSCodeExtensions.js +33 -0
  35. package/src/commands/init/installVSCodeExtensions.js.map +1 -0
  36. package/src/commands/init/promptSaveSlot.d.ts +1 -0
  37. package/src/commands/init/promptSaveSlot.js +25 -0
  38. package/src/commands/init/promptSaveSlot.js.map +1 -0
  39. package/src/commands/init/promptVSCode.d.ts +1 -0
  40. package/src/commands/init/promptVSCode.js +27 -0
  41. package/src/commands/init/promptVSCode.js.map +1 -0
  42. package/src/commands/monitor/constants.d.ts +1 -0
  43. package/{dist/src → src}/commands/monitor/constants.js +4 -4
  44. package/src/commands/monitor/constants.js.map +1 -0
  45. package/src/commands/monitor/copyWatcherMod.d.ts +2 -0
  46. package/{dist/src → src}/commands/monitor/copyWatcherMod.js +38 -63
  47. package/src/commands/monitor/copyWatcherMod.js.map +1 -0
  48. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.d.ts +1 -0
  49. package/{dist/src → src}/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +49 -51
  50. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +1 -0
  51. package/src/commands/monitor/monitor.d.ts +2 -0
  52. package/{dist/src → src}/commands/monitor/monitor.js +146 -171
  53. package/src/commands/monitor/monitor.js.map +1 -0
  54. package/src/commands/monitor/notifyGame.d.ts +3 -0
  55. package/{dist/src → src}/commands/monitor/notifyGame.js +57 -59
  56. package/src/commands/monitor/notifyGame.js.map +1 -0
  57. package/src/commands/monitor/saveDatWriter/saveDatWriter.d.ts +1 -0
  58. package/{dist/src → src}/commands/monitor/saveDatWriter/saveDatWriter.js +116 -141
  59. package/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -0
  60. package/src/commands/monitor/saveDatWriter/types.d.ts +5 -0
  61. package/{dist/src → src}/commands/monitor/saveDatWriter/types.js +2 -2
  62. package/src/commands/monitor/saveDatWriter/types.js.map +1 -0
  63. package/src/commands/monitor/spawnSaveDatWriter.d.ts +4 -0
  64. package/{dist/src → src}/commands/monitor/spawnSaveDatWriter.js +34 -36
  65. package/src/commands/monitor/spawnSaveDatWriter.js.map +1 -0
  66. package/src/commands/monitor/touchWatcherSaveDatFiles.d.ts +2 -0
  67. package/src/commands/monitor/touchWatcherSaveDatFiles.js +21 -0
  68. package/src/commands/monitor/touchWatcherSaveDatFiles.js.map +1 -0
  69. package/src/commands/publish/publish.d.ts +2 -0
  70. package/{dist/src → src}/commands/publish/publish.js +220 -260
  71. package/src/commands/publish/publish.js.map +1 -0
  72. package/src/configFile.d.ts +4 -0
  73. package/src/configFile.js +66 -0
  74. package/src/configFile.js.map +1 -0
  75. package/src/constants.d.ts +34 -0
  76. package/{dist/src → src}/constants.js +59 -61
  77. package/src/constants.js.map +1 -0
  78. package/src/exec.d.ts +4 -0
  79. package/{dist/src → src}/exec.js +95 -97
  80. package/src/exec.js.map +1 -0
  81. package/src/file.d.ts +12 -0
  82. package/{dist/src → src}/file.js +193 -195
  83. package/src/file.js.map +1 -0
  84. package/src/main.d.ts +2 -0
  85. package/src/main.js +122 -0
  86. package/src/main.js.map +1 -0
  87. package/src/parseArgs.d.ts +1 -0
  88. package/{dist/src → src}/parseArgs.js +106 -108
  89. package/src/parseArgs.js.map +1 -0
  90. package/src/prompt.d.ts +5 -0
  91. package/src/prompt.js +93 -0
  92. package/src/prompt.js.map +1 -0
  93. package/src/types/Command.d.ts +2 -0
  94. package/{dist/src → src}/types/Command.js +4 -4
  95. package/src/types/Command.js.map +1 -0
  96. package/src/types/Config.d.ts +18 -0
  97. package/{dist/src → src}/types/Config.js +12 -12
  98. package/src/types/Config.js.map +1 -0
  99. package/src/types/GitHubCLIHostsYAML.d.ts +7 -0
  100. package/{dist/src → src}/types/GitHubCLIHostsYAML.js +2 -2
  101. package/src/types/GitHubCLIHostsYAML.js.map +1 -0
  102. package/src/utils.d.ts +13 -0
  103. package/{dist/src → src}/utils.js +81 -83
  104. package/src/utils.js.map +1 -0
  105. package/src/validateInIsaacScriptProject.d.ts +1 -0
  106. package/src/validateInIsaacScriptProject.js +27 -0
  107. package/src/validateInIsaacScriptProject.js.map +1 -0
  108. package/src/validateNodeVersion.d.ts +5 -0
  109. package/{dist/src → src}/validateNodeVersion.js +24 -26
  110. package/src/validateNodeVersion.js.map +1 -0
  111. package/src/validateOS.d.ts +1 -0
  112. package/{dist/src → src}/validateOS.js +16 -18
  113. package/src/validateOS.js.map +1 -0
  114. package/LICENSE +0 -674
  115. package/dist/package.json +0 -57
  116. package/dist/src/checkForWindowsTerminalBugs.js +0 -101
  117. package/dist/src/commands/copy/copy.js +0 -58
  118. package/dist/src/commands/init/checkIfProjectPathExists.js +0 -53
  119. package/dist/src/commands/init/checkModSubdirectory.js +0 -41
  120. package/dist/src/commands/init/checkModTargetDirectory.js +0 -56
  121. package/dist/src/commands/init/getModsDir.js +0 -81
  122. package/dist/src/commands/init/getProjectPath.js +0 -91
  123. package/dist/src/commands/init/init.js +0 -68
  124. package/dist/src/commands/init/installVSCodeExtensions.js +0 -58
  125. package/dist/src/commands/init/promptSaveSlot.js +0 -22
  126. package/dist/src/commands/init/promptVSCode.js +0 -27
  127. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js +0 -46
  128. package/dist/src/configFile.js +0 -89
  129. package/dist/src/main.js +0 -136
  130. package/dist/src/prompt.js +0 -89
  131. package/dist/src/validateInIsaacScriptProject.js +0 -52
  132. package/isaacscript-watcher/.luacheckrc +0 -96
  133. package/isaacscript-watcher/README.md +0 -8
  134. package/isaacscript-watcher/main.lua +0 -270
  135. package/isaacscript-watcher/metadata.xml +0 -7
  136. package/isaacscript-watcher/resources/gfx/logo.anm2 +0 -27
  137. package/isaacscript-watcher/resources/gfx/logo.png +0 -0
@@ -1,60 +1,58 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ping = exports.command = exports.msg = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const utils_1 = require("../../utils");
9
- const constants_1 = require("./constants");
10
- const spawnSaveDatWriter_1 = require("./spawnSaveDatWriter");
11
- function msg(data) {
12
- const formattedData = data
13
- .replace(/\r\n/g, "\n") // Replace Windows newlines with Unix newlines
14
- .trim(); // Trim whitespace
15
- for (const line of formattedData.split("\n")) {
16
- const trimmedLine = line.trim();
17
- if (trimmedLine === "") {
18
- continue;
19
- }
20
- // Ignore the final message from tstl upon exiting the program.
21
- if (trimmedLine === "Terminate batch job (Y/N)?") {
22
- return;
23
- }
24
- // Add a time prefix.
25
- const formattedLine = `[${(0, utils_1.getTime)()}] ${trimmedLine}`;
26
- (0, spawnSaveDatWriter_1.sendMsgToSaveDatWriter)({
27
- type: "msg",
28
- data: formattedLine,
29
- });
30
- // We also print the message to standard out so that the end-user can choose between reading
31
- // tstl errors from the IsaacScript terminal window or from looking at the in-game output.
32
- printMsgToStandardOut(formattedLine);
33
- }
34
- }
35
- exports.msg = msg;
36
- function printMsgToStandardOut(data) {
37
- let coloredData = data;
38
- if (data.includes(constants_1.COMPILATION_SUCCESSFUL)) {
39
- coloredData = chalk_1.default.green(data);
40
- }
41
- else if (data.match(/error/g) !== null) {
42
- coloredData = chalk_1.default.red(data);
43
- }
44
- console.log(coloredData);
45
- }
46
- function command(data) {
47
- (0, spawnSaveDatWriter_1.sendMsgToSaveDatWriter)({
48
- type: "command",
49
- data,
50
- });
51
- }
52
- exports.command = command;
53
- function ping() {
54
- (0, spawnSaveDatWriter_1.sendMsgToSaveDatWriter)({
55
- type: "ping",
56
- data: "",
57
- });
58
- }
59
- exports.ping = ping;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ping = exports.command = exports.msg = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const utils_1 = require("../../utils");
7
+ const constants_1 = require("./constants");
8
+ const spawnSaveDatWriter_1 = require("./spawnSaveDatWriter");
9
+ function msg(data) {
10
+ const formattedData = data
11
+ .replace(/\r\n/g, "\n") // Replace Windows newlines with Unix newlines
12
+ .trim(); // Trim whitespace
13
+ for (const line of formattedData.split("\n")) {
14
+ const trimmedLine = line.trim();
15
+ if (trimmedLine === "") {
16
+ continue;
17
+ }
18
+ // Ignore the final message from tstl upon exiting the program.
19
+ if (trimmedLine === "Terminate batch job (Y/N)?") {
20
+ return;
21
+ }
22
+ // Add a time prefix.
23
+ const formattedLine = `[${(0, utils_1.getTime)()}] ${trimmedLine}`;
24
+ (0, spawnSaveDatWriter_1.sendMsgToSaveDatWriter)({
25
+ type: "msg",
26
+ data: formattedLine,
27
+ });
28
+ // We also print the message to standard out so that the end-user can choose between reading
29
+ // tstl errors from the IsaacScript terminal window or from looking at the in-game output.
30
+ printMsgToStandardOut(formattedLine);
31
+ }
32
+ }
33
+ exports.msg = msg;
34
+ function printMsgToStandardOut(data) {
35
+ let coloredData = data;
36
+ if (data.includes(constants_1.COMPILATION_SUCCESSFUL)) {
37
+ coloredData = chalk_1.default.green(data);
38
+ }
39
+ else if (data.match(/error/g) !== null) {
40
+ coloredData = chalk_1.default.red(data);
41
+ }
42
+ console.log(coloredData);
43
+ }
44
+ function command(data) {
45
+ (0, spawnSaveDatWriter_1.sendMsgToSaveDatWriter)({
46
+ type: "command",
47
+ data,
48
+ });
49
+ }
50
+ exports.command = command;
51
+ function ping() {
52
+ (0, spawnSaveDatWriter_1.sendMsgToSaveDatWriter)({
53
+ type: "ping",
54
+ data: "",
55
+ });
56
+ }
57
+ exports.ping = ping;
60
58
  //# sourceMappingURL=notifyGame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifyGame.js","sourceRoot":"","sources":["../../../../../../packages/isaacscript-cli/src/commands/monitor/notifyGame.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,uCAAsC;AACtC,2CAAqD;AACrD,6DAA8D;AAE9D,SAAgB,GAAG,CAAC,IAAY;IAC9B,MAAM,aAAa,GAAG,IAAI;SACvB,OAAO,CAAC,OAAO,EAAE,IAAI,C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,oBAKC"}
@@ -1,142 +1,117 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const JSONC = __importStar(require("jsonc-parser"));
30
- const path_1 = __importDefault(require("path"));
31
- const constants_1 = require("../../../constants");
32
- const file = __importStar(require("../../../file"));
33
- const utils_1 = require("../../../utils");
34
- const SUBPROCESS_NAME = "save#.dat writer";
35
- const BASE_ARGV_LENGTH = 2;
36
- const MAX_MESSAGES = 100;
37
- const VERBOSE = false;
38
- let saveDatPath;
39
- let saveDatFileName;
40
- init(VERBOSE);
41
- function init(verbose) {
42
- const firstArg = process.argv[BASE_ARGV_LENGTH];
43
- if (firstArg === undefined) {
44
- throw new Error(`The ${SUBPROCESS_NAME} process did not get a valid first argument.`);
45
- }
46
- saveDatPath = firstArg;
47
- saveDatFileName = path_1.default.basename(saveDatPath);
48
- // Check to see if the data directory exists.
49
- const watcherModDataPath = path_1.default.dirname(saveDatPath);
50
- if (!file.exists(watcherModDataPath, verbose)) {
51
- file.makeDir(watcherModDataPath, verbose);
52
- }
53
- // Listen for messages from the parent process.
54
- process.on("message", (msg) => {
55
- onMessage(msg.type, msg.data);
56
- });
57
- }
58
- function onMessage(type, data, numRetries = 0) {
59
- const saveDat = readSaveDatFromDisk(VERBOSE);
60
- if (saveDat.length > MAX_MESSAGES) {
61
- // If IsaacScript is running and:
62
- // - the game is not open
63
- // - or the game is open but the IsaacScript Watcher mod is disabled
64
- //
65
- // Then this process will continue to write to the "save#.dat" file, which can cause it to grow
66
- // arbitrarily large (since there is no-one on the other side removing the messages). If there
67
- // is N messages already in the queue, assume that no-one is listening and stop adding any more
68
- // messages.
69
- return;
70
- }
71
- addMessageToSaveDat(type, saveDat, data); // Mutates saveDat
72
- writeSaveDatToDisk(type, data, saveDat, numRetries, VERBOSE);
73
- }
74
- function readSaveDatFromDisk(verbose) {
75
- let saveDat;
76
- if (file.exists(saveDatPath, verbose)) {
77
- const saveDatRaw = file.read(saveDatPath, verbose);
78
- try {
79
- saveDat = JSONC.parse(saveDatRaw);
80
- }
81
- catch (err) {
82
- send(`Failed to parse "${saveDatPath}": ${err}`);
83
- process.exit(1);
84
- }
85
- }
86
- else {
87
- saveDat = [];
88
- }
89
- if (!Array.isArray(saveDat)) {
90
- saveDat = [];
91
- }
92
- return saveDat;
93
- }
94
- function addMessageToSaveDat(type, saveDat, data) {
95
- switch (type) {
96
- case "command":
97
- case "ping": {
98
- saveDat.push({
99
- type,
100
- data,
101
- });
102
- break;
103
- }
104
- case "msg": {
105
- const lines = data.split("\n");
106
- for (const line of lines) {
107
- saveDat.push({
108
- type,
109
- data: line,
110
- });
111
- }
112
- break;
113
- }
114
- default: {
115
- (0, utils_1.ensureAllCases)(type);
116
- break;
117
- }
118
- }
119
- }
120
- function writeSaveDatToDisk(type, data, saveDat, numRetries, verbose) {
121
- const saveDatRaw = JSON.stringify(saveDat, null, 2);
122
- try {
123
- file.writeTry(saveDatPath, saveDatRaw, verbose);
124
- }
125
- catch (err) {
126
- if (numRetries > 4) {
127
- send(`Failed to write to the ${saveDatFileName} for 5 times in a row. Maybe the file got locked somehow. ${constants_1.PROJECT_NAME} will now exit.`);
128
- send(`The writing error is as follows: ${err}`);
129
- process.exit(1);
130
- }
131
- send(`Writing to "${saveDatFileName}" failed. (The number of retries so far is ${numRetries}.) Trying again in 0.1 seconds...`);
132
- setTimeout(() => {
133
- onMessage(type, data, numRetries + 1);
134
- }, 100);
135
- }
136
- }
137
- function send(msg) {
138
- if (process.send !== undefined) {
139
- process.send(msg);
140
- }
141
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const JSONC = tslib_1.__importStar(require("jsonc-parser"));
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
+ const constants_1 = require("../../../constants");
7
+ const file = tslib_1.__importStar(require("../../../file"));
8
+ const utils_1 = require("../../../utils");
9
+ const SUBPROCESS_NAME = "save#.dat writer";
10
+ const BASE_ARGV_LENGTH = 2;
11
+ const MAX_MESSAGES = 100;
12
+ const VERBOSE = false;
13
+ let saveDatPath;
14
+ let saveDatFileName;
15
+ init(VERBOSE);
16
+ function init(verbose) {
17
+ const firstArg = process.argv[BASE_ARGV_LENGTH];
18
+ if (firstArg === undefined) {
19
+ throw new Error(`The ${SUBPROCESS_NAME} process did not get a valid first argument.`);
20
+ }
21
+ saveDatPath = firstArg;
22
+ saveDatFileName = path_1.default.basename(saveDatPath);
23
+ // Check to see if the data directory exists.
24
+ const watcherModDataPath = path_1.default.dirname(saveDatPath);
25
+ if (!file.exists(watcherModDataPath, verbose)) {
26
+ file.makeDir(watcherModDataPath, verbose);
27
+ }
28
+ // Listen for messages from the parent process.
29
+ process.on("message", (msg) => {
30
+ onMessage(msg.type, msg.data);
31
+ });
32
+ }
33
+ function onMessage(type, data, numRetries = 0) {
34
+ const saveDat = readSaveDatFromDisk(VERBOSE);
35
+ if (saveDat.length > MAX_MESSAGES) {
36
+ // If IsaacScript is running and:
37
+ // - the game is not open
38
+ // - or the game is open but the IsaacScript Watcher mod is disabled
39
+ //
40
+ // Then this process will continue to write to the "save#.dat" file, which can cause it to grow
41
+ // arbitrarily large (since there is no-one on the other side removing the messages). If there
42
+ // is N messages already in the queue, assume that no-one is listening and stop adding any more
43
+ // messages.
44
+ return;
45
+ }
46
+ addMessageToSaveDat(type, saveDat, data); // Mutates saveDat
47
+ writeSaveDatToDisk(type, data, saveDat, numRetries, VERBOSE);
48
+ }
49
+ function readSaveDatFromDisk(verbose) {
50
+ let saveDat;
51
+ if (file.exists(saveDatPath, verbose)) {
52
+ const saveDatRaw = file.read(saveDatPath, verbose);
53
+ try {
54
+ saveDat = JSONC.parse(saveDatRaw);
55
+ }
56
+ catch (err) {
57
+ send(`Failed to parse "${saveDatPath}": ${err}`);
58
+ process.exit(1);
59
+ }
60
+ }
61
+ else {
62
+ saveDat = [];
63
+ }
64
+ if (!Array.isArray(saveDat)) {
65
+ saveDat = [];
66
+ }
67
+ return saveDat;
68
+ }
69
+ function addMessageToSaveDat(type, saveDat, data) {
70
+ switch (type) {
71
+ case "command":
72
+ case "ping": {
73
+ saveDat.push({
74
+ type,
75
+ data,
76
+ });
77
+ break;
78
+ }
79
+ case "msg": {
80
+ const lines = data.split("\n");
81
+ for (const line of lines) {
82
+ saveDat.push({
83
+ type,
84
+ data: line,
85
+ });
86
+ }
87
+ break;
88
+ }
89
+ default: {
90
+ (0, utils_1.ensureAllCases)(type);
91
+ break;
92
+ }
93
+ }
94
+ }
95
+ function writeSaveDatToDisk(type, data, saveDat, numRetries, verbose) {
96
+ const saveDatRaw = JSON.stringify(saveDat, null, 2);
97
+ try {
98
+ file.writeTry(saveDatPath, saveDatRaw, verbose);
99
+ }
100
+ catch (err) {
101
+ if (numRetries > 4) {
102
+ send(`Failed to write to the ${saveDatFileName} for 5 times in a row. Maybe the file got locked somehow. ${constants_1.PROJECT_NAME} will now exit.`);
103
+ send(`The writing error is as follows: ${err}`);
104
+ process.exit(1);
105
+ }
106
+ send(`Writing to "${saveDatFileName}" failed. (The number of retries so far is ${numRetries}.) Trying again in 0.1 seconds...`);
107
+ setTimeout(() => {
108
+ onMessage(type, data, numRetries + 1);
109
+ }, 100);
110
+ }
111
+ }
112
+ function send(msg) {
113
+ if (process.send !== undefined) {
114
+ process.send(msg);
115
+ }
116
+ }
142
117
  //# sourceMappingURL=saveDatWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saveDatWriter.js","sourceRoot":"","sources":["../../../../../../../packages/isaacscript-cli/src/commands/monitor/saveDatWriter/saveDatWriter.ts"],"names":[],"mappings":";;;AAAA,4DAAsC;AACtC,wDAAwB;AACxB,kDAAkD;AAClD,4DAAsC;AACtC,0CAAgD;AAGhD,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,OAAO,GAAG,KAAK,CAAC;AAEtB,IAAI,WAAmB,CAAC;AACxB,IAAI,eAAuB,CAAC;AAE5B,IAAI,CAAC,OAAO,CAAC,CAAC;AAEd,SAAS,IAAI,CAAC,OAAgB;IAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChD,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,MAAM,IAAI,KAAK,CACb,OAAO,eAAe,8CAA8C,CACrE,CAAC;KACH;IAED,WAAW,GAAG,QAAQ,CAAC;IACvB,eAAe,GAAG,cAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAE7C,6CAA6C;IAC7C,MAAM,kBAAkB,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACrD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,EAAE;QAC7C,IAAI,CAAC,OAAO,CA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AAE;YACd,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC,EAAE,GAAG,CAAC,CAAC;KACT;AACH,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;QAC9B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnB;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare type SaveDatMessageType = "command" | "msg" | "ping";
2
+ export interface SaveDatMessage {
3
+ type: SaveDatMessageType;
4
+ data: string;
5
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/isaacscript-cli/src/commands/monitor/saveDatWriter/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { Config } from "../../types/Config";
2
+ import { SaveDatMessage } from "./saveDatWriter/types";
3
+ export declare function spawnSaveDatWriter(config: Config): void;
4
+ export declare function sendMsgToSaveDatWriter(msg: SaveDatMessage): void;
@@ -1,37 +1,35 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.sendMsgToSaveDatWriter = exports.spawnSaveDatWriter = void 0;
7
- const child_process_1 = require("child_process");
8
- const path_1 = __importDefault(require("path"));
9
- const constants_1 = require("../../constants");
10
- const utils_1 = require("../../utils");
11
- let saveDatWriter = null;
12
- function spawnSaveDatWriter(config) {
13
- const processName = "saveDatWriter";
14
- const processDescription = "save#.dat writer";
15
- const processPath = path_1.default.join(__dirname, processName, processName);
16
- const modsDataPath = path_1.default.join(config.modsDirectory, "..", "data");
17
- const watcherModDataPath = path_1.default.join(modsDataPath, constants_1.WATCHER_MOD_NAME);
18
- const saveDatFileName = `save${config.saveSlot}.dat`;
19
- const saveDatPath = path_1.default.join(watcherModDataPath, saveDatFileName);
20
- saveDatWriter = (0, child_process_1.fork)(processPath, [saveDatPath], {
21
- stdio: ["pipe", "pipe", "pipe", "ipc"],
22
- });
23
- saveDatWriter.on("close", (code) => {
24
- (0, utils_1.error)(`Error: ${processDescription} subprocess closed with code: ${code}`);
25
- });
26
- saveDatWriter.on("exit", (code) => {
27
- (0, utils_1.error)(`Error: ${processDescription} subprocess exited with code: ${code}`);
28
- });
29
- }
30
- exports.spawnSaveDatWriter = spawnSaveDatWriter;
31
- function sendMsgToSaveDatWriter(msg) {
32
- if (saveDatWriter !== null) {
33
- saveDatWriter.send(msg);
34
- }
35
- }
36
- exports.sendMsgToSaveDatWriter = sendMsgToSaveDatWriter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendMsgToSaveDatWriter = exports.spawnSaveDatWriter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const child_process_1 = require("child_process");
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
+ const constants_1 = require("../../constants");
8
+ const utils_1 = require("../../utils");
9
+ let saveDatWriter = null;
10
+ function spawnSaveDatWriter(config) {
11
+ const processName = "saveDatWriter";
12
+ const processDescription = "save#.dat writer";
13
+ const processPath = path_1.default.join(__dirname, processName, processName);
14
+ const modsDataPath = path_1.default.join(config.modsDirectory, "..", "data");
15
+ const watcherModDataPath = path_1.default.join(modsDataPath, constants_1.WATCHER_MOD_NAME);
16
+ const saveDatFileName = `save${config.saveSlot}.dat`;
17
+ const saveDatPath = path_1.default.join(watcherModDataPath, saveDatFileName);
18
+ saveDatWriter = (0, child_process_1.fork)(processPath, [saveDatPath], {
19
+ stdio: ["pipe", "pipe", "pipe", "ipc"],
20
+ });
21
+ saveDatWriter.on("close", (code) => {
22
+ (0, utils_1.error)(`Error: ${processDescription} subprocess closed with code: ${code}`);
23
+ });
24
+ saveDatWriter.on("exit", (code) => {
25
+ (0, utils_1.error)(`Error: ${processDescription} subprocess exited with code: ${code}`);
26
+ });
27
+ }
28
+ exports.spawnSaveDatWriter = spawnSaveDatWriter;
29
+ function sendMsgToSaveDatWriter(msg) {
30
+ if (saveDatWriter !== null) {
31
+ saveDatWriter.send(msg);
32
+ }
33
+ }
34
+ exports.sendMsgToSaveDatWriter = sendMsgToSaveDatWriter;
37
35
  //# sourceMappingURL=spawnSaveDatWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawnSaveDatWriter.js","sourceRoot":"","sources":["../../../../../../packages/isaacscript-cli/src/commands/monitor/spawnSaveDatWriter.ts"],"names":[],"mappings":";;;;AAAA,iDAAmD;AACnD,wDAAwB;AACxB,+CAAmD;AAEnD,uCAAoC;AAGpC,IAAI,aAAa,GAAwB,IAAI,CAAC;AAE9C,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,MAAM,WAAW,GAAG,eAAe,CAAC;IACpC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;IAC9C,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACnE,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACnE,MAAM,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,4BAAgB,CAAC,CAAC;IACrE,MAAM,eAAe,GAAG,OAAO,MAAM,CAAC,QAAQ,MAAM,CAAC;IACrD,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;IAEnE,aAAa,GAAG,IAAA,oBAAI,EAAC,WAAW,EAAE,CAAC,WAAW,CAAC,EAAE;QAC/C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;KACvC,CAAC,CAAC;IAEH,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAmB,EAAE,EAAE;QAChD,IAAA,aAAK,EAAC,UAAU,kBAAkB,iCAAiC,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAmB,EAAE,EAAE;QAC/C,IAAA,aAAK,EAAC,UAAU,kBAAkB,iCAAiC,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC;AApBD,gDAoBC;AAED,SAAgB,sBAAsB,CAAC,GAAmB;IACxD,IAAI,aAAa,KAAK,IAAI,EAAE;QAC1B,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACzB;AACH,CAAC;AAJD,wDAIC"}
@@ -0,0 +1,2 @@
1
+ import { Config } from "../../types/Config";
2
+ export declare function touchWatcherSaveDatFiles(config: Config, verbose: boolean): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.touchWatcherSaveDatFiles = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
+ const constants_1 = require("../../constants");
7
+ const file = tslib_1.__importStar(require("../../file"));
8
+ function touchWatcherSaveDatFiles(config, verbose) {
9
+ const modsDataPath = path_1.default.join(config.modsDirectory, "..", "data");
10
+ const watcherModDataPath = path_1.default.join(modsDataPath, constants_1.WATCHER_MOD_NAME);
11
+ if (!file.exists(watcherModDataPath, verbose)) {
12
+ file.makeDir(watcherModDataPath, verbose);
13
+ }
14
+ const saveDatFileName = `save${config.saveSlot}.dat`;
15
+ const saveDatPath = path_1.default.join(watcherModDataPath, saveDatFileName);
16
+ if (!file.exists(saveDatPath, verbose)) {
17
+ file.touch(saveDatPath, verbose);
18
+ }
19
+ }
20
+ exports.touchWatcherSaveDatFiles = touchWatcherSaveDatFiles;
21
+ //# sourceMappingURL=touchWatcherSaveDatFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"touchWatcherSaveDatFiles.js","sourceRoot":"","sources":["../../../../../../packages/isaacscript-cli/src/commands/monitor/touchWatcherSaveDatFiles.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,+CAAmD;AACnD,yDAAmC;AAGnC,SAAgB,wBAAwB,CACtC,MAAc,EACd,OAAgB;IAEhB,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACnE,MAAM,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,4BAAgB,CAAC,CAAC;IACrE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,EAAE;QAC7C,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;KAC3C;IACD,MAAM,eAAe,GAAG,OAAO,MAAM,CAAC,QAAQ,MAAM,CAAC;IACrD,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;IACnE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;QACtC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;KAClC;AACH,CAAC;AAdD,4DAcC"}
@@ -0,0 +1,2 @@
1
+ import { Config } from "../../types/Config";
2
+ export declare function publish(argv: Record<string, unknown>, config: Config): void;