isaacscript 1.2.25 → 1.2.28
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.
- package/dist/package.json +7 -6
- package/dist/src/commands/copy/copy.js +0 -1
- package/dist/src/commands/copy/copy.js.map +1 -1
- package/dist/src/commands/init/createMod.js +18 -106
- package/dist/src/commands/init/createMod.js.map +1 -1
- package/dist/src/commands/init/getProjectPath.js +4 -2
- package/dist/src/commands/init/getProjectPath.js.map +1 -1
- package/dist/src/commands/init/git.js +167 -0
- package/dist/src/commands/init/git.js.map +1 -0
- package/dist/src/commands/init/init.js +3 -1
- package/dist/src/commands/init/init.js.map +1 -1
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +0 -5
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +1 -1
- package/dist/src/commands/publish/publish.js +4 -21
- package/dist/src/commands/publish/publish.js.map +1 -1
- package/dist/src/configFile.js +2 -2
- package/dist/src/configFile.js.map +1 -1
- package/dist/src/prompt.js +1 -0
- package/dist/src/prompt.js.map +1 -1
- package/file-templates/static/.github/workflows/ci.yml +3 -3
- package/{src → file-templates/static}/plugins/addCrashDebugStatements.ts +0 -0
- package/file-templates/static/plugins/addIsaacScriptCommentHeader.ts +35 -0
- package/file-templates/static/tsconfig.json +8 -0
- package/isaacscript-watcher/metadata.xml +5 -5
- package/package.json +7 -6
- package/src/commands/copy/copy.ts +0 -1
- package/src/commands/init/createMod.ts +29 -188
- package/src/commands/init/getProjectPath.ts +5 -3
- package/src/commands/init/git.ts +232 -0
- package/src/commands/init/init.ts +8 -1
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +0 -6
- package/src/commands/publish/publish.ts +4 -26
- package/src/configFile.ts +3 -3
- package/src/exec.ts +1 -1
- package/src/prompt.ts +1 -0
- package/dist/src/monkeyPatch.js +0 -82
- package/dist/src/monkeyPatch.js.map +0 -1
- package/dist/src/plugins/addCrashDebugStatements.js +0 -44
- package/dist/src/plugins/addCrashDebugStatements.js.map +0 -1
- package/src/monkeyPatch.ts +0 -62
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import commandExists from "command-exists";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import yaml from "yaml";
|
|
5
|
+
import { PROJECT_NAME } from "../../constants";
|
|
6
|
+
import { execShell } from "../../exec";
|
|
7
|
+
import * as file from "../../file";
|
|
8
|
+
import { getInputString, getInputYesNo } from "../../prompt";
|
|
9
|
+
import { GitHubCLIHostsYAML } from "../../types/GitHubCLIHostsYAML";
|
|
10
|
+
import { error, parseSemVer } from "../../utils";
|
|
11
|
+
|
|
12
|
+
const REQUIRED_GIT_MAJOR_VERSION = 2;
|
|
13
|
+
const REQUIRED_GIT_MINOR_VERSION = 30;
|
|
14
|
+
|
|
15
|
+
export async function promptGitHubRepoOrGitRemoteURL(
|
|
16
|
+
projectName: string,
|
|
17
|
+
verbose: boolean,
|
|
18
|
+
): Promise<string | undefined> {
|
|
19
|
+
// We do not need to prompt the user if they do not have Git installed
|
|
20
|
+
if (!commandExists.sync("git")) {
|
|
21
|
+
console.log(
|
|
22
|
+
'Git does not seem to be installed. (The "git" command is not in the path.) Skipping Git-related things.',
|
|
23
|
+
);
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
validateNewGitVersion(verbose);
|
|
28
|
+
|
|
29
|
+
const gitHubUsername = getGitHubUsername();
|
|
30
|
+
if (gitHubUsername !== undefined) {
|
|
31
|
+
const [exitStatus] = execShell(
|
|
32
|
+
"gh",
|
|
33
|
+
["repo", "view", projectName],
|
|
34
|
+
verbose,
|
|
35
|
+
true,
|
|
36
|
+
);
|
|
37
|
+
const gitHubRepoExists = exitStatus === 0;
|
|
38
|
+
const url = `https://github.com/${gitHubUsername}/${projectName}`;
|
|
39
|
+
|
|
40
|
+
if (gitHubRepoExists) {
|
|
41
|
+
console.log(
|
|
42
|
+
`Detected an existing GitHub repository at: ${chalk.green(url)}`,
|
|
43
|
+
);
|
|
44
|
+
const guessedRemoteURL = getGitRemoteURL(projectName, gitHubUsername);
|
|
45
|
+
const shouldUseGuessedURL = await getInputYesNo(
|
|
46
|
+
`Do you want to use a Git remote URL of: ${chalk.green(
|
|
47
|
+
guessedRemoteURL,
|
|
48
|
+
)}`,
|
|
49
|
+
);
|
|
50
|
+
if (shouldUseGuessedURL) {
|
|
51
|
+
return guessedRemoteURL;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Assume that since they do not want to connect this project to the existing GitHub
|
|
55
|
+
// repository, they do not want to initialize Git either
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const createNewGitHubRepo = await getInputYesNo(
|
|
60
|
+
`Would you like to create a new GitHub repository at: ${chalk.green(
|
|
61
|
+
url,
|
|
62
|
+
)}`,
|
|
63
|
+
);
|
|
64
|
+
if (createNewGitHubRepo) {
|
|
65
|
+
execShell("gh", ["repo", "create", "poop", "--public"]);
|
|
66
|
+
console.log("Successfully created a new GitHub repository.");
|
|
67
|
+
return getGitRemoteURL(projectName, gitHubUsername);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Assume that since they do not want to create a new GitHub repository, they do not want to
|
|
71
|
+
// initialize Git either
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const gitRemoteURL =
|
|
76
|
+
await getInputString(`Paste in the remote Git URL for your project.
|
|
77
|
+
For example, if you have an SSH key, it would be something like:
|
|
78
|
+
${chalk.green("git@github.com:Alice/green-candle.git")}
|
|
79
|
+
If you don't have an SSH key, it would be something like:
|
|
80
|
+
${chalk.green("https://github.com/Alice/green-candle.git")}
|
|
81
|
+
If you don't want to initialize a Git repository for this project, press enter to skip.
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
return gitRemoteURL === "" ? undefined : gitRemoteURL;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function validateNewGitVersion(verbose: boolean) {
|
|
88
|
+
const [, stdout] = execShell("git", ["--version"], verbose);
|
|
89
|
+
|
|
90
|
+
const outputPrefix = "git version ";
|
|
91
|
+
if (!stdout.startsWith(outputPrefix)) {
|
|
92
|
+
error(
|
|
93
|
+
`Failed to parse the output from the "git --version" command: ${stdout}`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const gitVersionString = stdout.slice(outputPrefix.length);
|
|
98
|
+
const [majorVersion, minorVersion] = parseSemVer(gitVersionString);
|
|
99
|
+
|
|
100
|
+
if (
|
|
101
|
+
majorVersion >= REQUIRED_GIT_MAJOR_VERSION &&
|
|
102
|
+
minorVersion >= REQUIRED_GIT_MINOR_VERSION
|
|
103
|
+
) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.error(`Your Git version is: ${chalk.red(gitVersionString)}`);
|
|
108
|
+
console.error(
|
|
109
|
+
`${PROJECT_NAME} requires a Git version of ${chalk.red(
|
|
110
|
+
`${REQUIRED_GIT_MAJOR_VERSION}.${REQUIRED_GIT_MINOR_VERSION}.0`,
|
|
111
|
+
)} or greater.`,
|
|
112
|
+
);
|
|
113
|
+
console.error(
|
|
114
|
+
`Please upgrade your version of Git before using ${PROJECT_NAME}.`,
|
|
115
|
+
);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getGitHubUsername() {
|
|
120
|
+
// If the GitHub CLI is installed, we can derive the user's GitHub username
|
|
121
|
+
if (
|
|
122
|
+
!commandExists.sync("gh") ||
|
|
123
|
+
process.env.APPDATA === undefined ||
|
|
124
|
+
process.env.APPDATA === ""
|
|
125
|
+
) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const githubCLIHostsPath = path.join(
|
|
130
|
+
process.env.APPDATA,
|
|
131
|
+
"GitHub CLI",
|
|
132
|
+
"hosts.yml",
|
|
133
|
+
);
|
|
134
|
+
if (!file.exists(githubCLIHostsPath)) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const configYAMLRaw = file.read(githubCLIHostsPath);
|
|
139
|
+
const configYAML = yaml.parse(configYAMLRaw) as GitHubCLIHostsYAML;
|
|
140
|
+
|
|
141
|
+
const githubCom = configYAML["github.com"];
|
|
142
|
+
if (githubCom === undefined) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const { user } = githubCom;
|
|
147
|
+
if (user === "") {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return user;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function getGitRemoteURL(projectName: string, gitHubUsername: string) {
|
|
155
|
+
return `git@github.com:${gitHubUsername}/${projectName}.git`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function initGitRepository(
|
|
159
|
+
projectPath: string,
|
|
160
|
+
gitRemoteURL: string | undefined,
|
|
161
|
+
verbose: boolean,
|
|
162
|
+
): void {
|
|
163
|
+
// We already checked to see if the "git" command is installed earlier on in the initialization
|
|
164
|
+
// process
|
|
165
|
+
if (gitRemoteURL === undefined) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
execShell("git", ["init"], verbose, false, projectPath);
|
|
170
|
+
execShell("git", ["branch", "-M", "main"], verbose, false, projectPath);
|
|
171
|
+
execShell(
|
|
172
|
+
"git",
|
|
173
|
+
["remote", "add", "origin", gitRemoteURL],
|
|
174
|
+
verbose,
|
|
175
|
+
false,
|
|
176
|
+
projectPath,
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
if (isGitNameAndEmailConfigured(verbose)) {
|
|
180
|
+
execShell("git", ["add", "--all"], verbose, false, projectPath);
|
|
181
|
+
execShell(
|
|
182
|
+
"git",
|
|
183
|
+
["commit", "--message", `${PROJECT_NAME} template`],
|
|
184
|
+
verbose,
|
|
185
|
+
false,
|
|
186
|
+
projectPath,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function isGitNameAndEmailConfigured(verbose: boolean) {
|
|
192
|
+
const [nameExitStatus] = execShell(
|
|
193
|
+
"git",
|
|
194
|
+
["config", "--global", "user.name"],
|
|
195
|
+
verbose,
|
|
196
|
+
true,
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const [emailExitStatus] = execShell(
|
|
200
|
+
"git",
|
|
201
|
+
["config", "--global", "user.email"],
|
|
202
|
+
verbose,
|
|
203
|
+
true,
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
return nameExitStatus === 0 && emailExitStatus === 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function isGitDirty(verbose: boolean): boolean {
|
|
210
|
+
// From: https://remarkablemark.org/blog/2017/10/12/check-git-dirty/
|
|
211
|
+
const [, stdout] = execShell("git", ["status", "--porcelain"], verbose);
|
|
212
|
+
return stdout !== "";
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function gitCommitIfChanges(version: string, verbose: boolean): void {
|
|
216
|
+
// Throw an error if this is not a git repository
|
|
217
|
+
execShell("git", ["status"], verbose);
|
|
218
|
+
|
|
219
|
+
if (!isGitDirty(verbose)) {
|
|
220
|
+
console.log("There are no changes to commit.");
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const commitMessage = `v${version}`;
|
|
225
|
+
execShell("git", ["add", "-A"], verbose);
|
|
226
|
+
execShell("git", ["commit", "-m", commitMessage], verbose);
|
|
227
|
+
execShell("git", ["push"], verbose);
|
|
228
|
+
|
|
229
|
+
console.log(
|
|
230
|
+
`Committed and pushed to the git repository with a message of: ${commitMessage}`,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
@@ -8,6 +8,7 @@ import { checkModTargetDirectory } from "./checkModTargetDirectory";
|
|
|
8
8
|
import { createMod } from "./createMod";
|
|
9
9
|
import { getModsDir } from "./getModsDir";
|
|
10
10
|
import { getProjectPath } from "./getProjectPath";
|
|
11
|
+
import { promptGitHubRepoOrGitRemoteURL } from "./git";
|
|
11
12
|
import { installVSCodeExtensions } from "./installVSCodeExtensions";
|
|
12
13
|
import { promptSaveSlot } from "./promptSaveSlot";
|
|
13
14
|
import { promptVSCode } from "./promptVSCode";
|
|
@@ -25,16 +26,22 @@ export async function init(argv: Record<string, unknown>): Promise<void> {
|
|
|
25
26
|
const projectName = path.basename(projectPath);
|
|
26
27
|
await checkModTargetDirectory(modsDirectory, projectName, verbose);
|
|
27
28
|
const saveSlot = await promptSaveSlot(argv);
|
|
29
|
+
const gitRemoteURL = await promptGitHubRepoOrGitRemoteURL(
|
|
30
|
+
projectName,
|
|
31
|
+
verbose,
|
|
32
|
+
);
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
createMod(
|
|
30
35
|
projectName,
|
|
31
36
|
projectPath,
|
|
32
37
|
createNewDir,
|
|
33
38
|
modsDirectory,
|
|
34
39
|
saveSlot,
|
|
40
|
+
gitRemoteURL,
|
|
35
41
|
skipNPMInstall,
|
|
36
42
|
verbose,
|
|
37
43
|
);
|
|
44
|
+
|
|
38
45
|
await openVSCode(projectPath, vscode, verbose);
|
|
39
46
|
printFinishMessage(projectPath, projectName);
|
|
40
47
|
}
|
|
@@ -41,12 +41,6 @@ function afterEachSync(params?: {
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/*
|
|
45
|
-
if (params.relativePath === path.sep + MAIN_LUA) {
|
|
46
|
-
monkeyPatchMainLua(modTargetPath);
|
|
47
|
-
}
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
44
|
if (params.eventType !== "init:copy") {
|
|
51
45
|
send(`${FILE_SYNCED_MESSAGE} ${params.relativePath}`);
|
|
52
46
|
}
|
|
@@ -17,6 +17,7 @@ import * as file from "../../file";
|
|
|
17
17
|
import { Config } from "../../types/Config";
|
|
18
18
|
import { error, getModTargetDirectoryName, parseIntSafe } from "../../utils";
|
|
19
19
|
import { compileAndCopy } from "../copy/copy";
|
|
20
|
+
import { gitCommitIfChanges, isGitDirty } from "../init/git";
|
|
20
21
|
|
|
21
22
|
const UPDATE_SCRIPT_NAME = "update.sh";
|
|
22
23
|
|
|
@@ -89,7 +90,9 @@ function validateIsaacScriptOtherCopiesNotRunning(verbose: boolean) {
|
|
|
89
90
|
);
|
|
90
91
|
if (otherCopiesOfRunningIsaacScript.length > 0) {
|
|
91
92
|
error(
|
|
92
|
-
|
|
93
|
+
chalk.red(
|
|
94
|
+
`Other copies of ${PROJECT_NAME} appear to be running. You must close those copies before publishing.`,
|
|
95
|
+
),
|
|
93
96
|
);
|
|
94
97
|
}
|
|
95
98
|
}
|
|
@@ -287,31 +290,6 @@ function runReleaseScriptPostCopy(verbose: boolean) {
|
|
|
287
290
|
}
|
|
288
291
|
}
|
|
289
292
|
|
|
290
|
-
function gitCommitIfChanges(version: string, verbose: boolean) {
|
|
291
|
-
// Throw an error if this is not a git repository
|
|
292
|
-
execShell("git", ["status"], verbose);
|
|
293
|
-
|
|
294
|
-
if (!isGitDirty(verbose)) {
|
|
295
|
-
console.log("There are no changes to commit.");
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const commitMessage = `v${version}`;
|
|
300
|
-
execShell("git", ["add", "-A"], verbose);
|
|
301
|
-
execShell("git", ["commit", "-m", commitMessage], verbose);
|
|
302
|
-
execShell("git", ["push"], verbose);
|
|
303
|
-
|
|
304
|
-
console.log(
|
|
305
|
-
`Committed and pushed to the git repository with a message of: ${commitMessage}`,
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function isGitDirty(verbose: boolean) {
|
|
310
|
-
// From: https://remarkablemark.org/blog/2017/10/12/check-git-dirty/
|
|
311
|
-
const [, stdout] = execShell("git", ["status", "--porcelain"], verbose);
|
|
312
|
-
return stdout !== "";
|
|
313
|
-
}
|
|
314
|
-
|
|
315
293
|
function purgeRoomXMLs(modTargetPath: string, verbose: boolean) {
|
|
316
294
|
const roomsPath = path.join(modTargetPath, "resources", "rooms");
|
|
317
295
|
if (!file.exists(roomsPath) || !file.isDir(roomsPath)) {
|
package/src/configFile.ts
CHANGED
|
@@ -12,7 +12,7 @@ export async function get(argv: Record<string, unknown>): Promise<Config> {
|
|
|
12
12
|
const verbose = argv.verbose === true;
|
|
13
13
|
|
|
14
14
|
const existingConfig = readExistingConfig();
|
|
15
|
-
if (existingConfig !==
|
|
15
|
+
if (existingConfig !== undefined) {
|
|
16
16
|
return existingConfig;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -25,9 +25,9 @@ export async function get(argv: Record<string, unknown>): Promise<Config> {
|
|
|
25
25
|
return config;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function readExistingConfig(): Config |
|
|
28
|
+
function readExistingConfig(): Config | undefined {
|
|
29
29
|
if (!file.exists(CONFIG_FILE_PATH)) {
|
|
30
|
-
return
|
|
30
|
+
return undefined;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const configRaw = file.read(CONFIG_FILE_PATH);
|
package/src/exec.ts
CHANGED
|
@@ -59,7 +59,7 @@ export function execShell(
|
|
|
59
59
|
verbose = false,
|
|
60
60
|
allowFailure = false,
|
|
61
61
|
cwd = CWD,
|
|
62
|
-
): [number, string] {
|
|
62
|
+
): [exitStatus: number, stdout: string] {
|
|
63
63
|
// On Windows, "spawnSync()" will not account for spaces in arguments
|
|
64
64
|
// Thus, wrap everything in a double quote
|
|
65
65
|
// This will cause arguments that naturally have double quotes to fail
|
package/src/prompt.ts
CHANGED
package/dist/src/monkeyPatch.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
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 path_1 = __importDefault(require("path"));
|
|
30
|
-
const constants_1 = require("./constants");
|
|
31
|
-
const file = __importStar(require("./file"));
|
|
32
|
-
const INFORMATIONAL_HEADER = `--[[
|
|
33
|
-
|
|
34
|
-
This Isaac mod was created with the IsaacScript tool.
|
|
35
|
-
|
|
36
|
-
The Lua code in this file was automatically generated from higher-level TypeScript code and might be
|
|
37
|
-
hard to read. If you want to understand how the code in this mod works, you should read the actual
|
|
38
|
-
TypeScript source code directly instead of trying to parse this file. Usually, the link to the
|
|
39
|
-
source code can be found in the mod's description on the Steam Workshop. If not, you can ask the mod
|
|
40
|
-
author directly if the source code is publicly available.
|
|
41
|
-
|
|
42
|
-
IsaacScript provides a lot of advantages over using raw Lua. For more information about the tool,
|
|
43
|
-
see the official website: https://isaacscript.github.io/
|
|
44
|
-
|
|
45
|
-
--]]
|
|
46
|
-
|
|
47
|
-
`;
|
|
48
|
-
const MAIN_LUA_REPLACEMENTS = [
|
|
49
|
-
// For TSTL v1.2.X-v1.3.3
|
|
50
|
-
// (fixed with GlassBrick's PR)
|
|
51
|
-
["WeakMap = __TS__Class()", "WeakMap = WeakMap or __TS__Class()"],
|
|
52
|
-
["WeakSet = __TS__Class()", "WeakSet = WeakSet or __TS__Class()"],
|
|
53
|
-
["Map = __TS__Class()", "Map = Map or __TS__Class()"],
|
|
54
|
-
["Set = __TS__Class()", "Set = Set or __TS__Class()"],
|
|
55
|
-
];
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
57
|
-
function monkeyPatchMainLua(targetModDirectory, verbose) {
|
|
58
|
-
const mainLuaPath = path_1.default.join(targetModDirectory, constants_1.MAIN_LUA);
|
|
59
|
-
const mainLua = file.read(mainLuaPath);
|
|
60
|
-
// mainLua = patchInformationalHeader(mainLua);
|
|
61
|
-
// mainLua = patchGlobalObjects(mainLua);
|
|
62
|
-
file.write(mainLuaPath, mainLua, verbose);
|
|
63
|
-
}
|
|
64
|
-
// Add an informational header for people who happen to be browsing the Lua output
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
66
|
-
function patchInformationalHeader(mainLua) {
|
|
67
|
-
return INFORMATIONAL_HEADER + mainLua;
|
|
68
|
-
}
|
|
69
|
-
// Some TSTL objects (such as Map and Set) are written as global variables,
|
|
70
|
-
// which can cause multiple mods written with IsaacScript to trample on one another
|
|
71
|
-
// Until TSTL has an official fix, monkey patch this
|
|
72
|
-
// We also make sure of this function to compose a stock comment header for curious people looking
|
|
73
|
-
// at the transpiled Lua code
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75
|
-
function patchGlobalObjects(originalMainLua) {
|
|
76
|
-
let mainLua = originalMainLua;
|
|
77
|
-
for (const [findString, replaceString] of MAIN_LUA_REPLACEMENTS) {
|
|
78
|
-
mainLua = mainLua.replace(findString, replaceString);
|
|
79
|
-
}
|
|
80
|
-
return mainLua;
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=monkeyPatch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"monkeyPatch.js","sourceRoot":"","sources":["../../src/monkeyPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,2CAAuC;AACvC,6CAA+B;AAE/B,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;CAe5B,CAAC;AAEF,MAAM,qBAAqB,GAAG;IAC5B,yBAAyB;IACzB,+BAA+B;IAC/B,CAAC,yBAAyB,EAAE,oCAAoC,CAAC;IACjE,CAAC,yBAAyB,EAAE,oCAAoC,CAAC;IACjE,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;IACrD,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;CACtD,CAAC;AAEF,6DAA6D;AAC7D,SAAS,kBAAkB,CAAC,kBAA0B,EAAE,OAAgB;IACtE,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,oBAAQ,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEvC,+CAA+C;IAC/C,yCAAyC;IAEzC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,kFAAkF;AAClF,6DAA6D;AAC7D,SAAS,wBAAwB,CAAC,OAAe;IAC/C,OAAO,oBAAoB,GAAG,OAAO,CAAC;AACxC,CAAC;AAED,2EAA2E;AAC3E,mFAAmF;AACnF,oDAAoD;AACpD,kGAAkG;AAClG,6BAA6B;AAC7B,6DAA6D;AAC7D,SAAS,kBAAkB,CAAC,eAAuB;IACjD,IAAI,OAAO,GAAG,eAAe,CAAC;IAE9B,KAAK,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,qBAAqB,EAAE;QAC/D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;KACtD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const crypto = __importStar(require("crypto"));
|
|
27
|
-
const tstl = __importStar(require("typescript-to-lua"));
|
|
28
|
-
class CustomPrinter extends tstl.LuaPrinter {
|
|
29
|
-
printStatement(statement) {
|
|
30
|
-
const uuid = crypto.randomUUID();
|
|
31
|
-
const debugLineToInsert = `Isaac.DebugString("CRASH DEBUG ${uuid}")\n`;
|
|
32
|
-
const originalResult = super.printStatement(statement);
|
|
33
|
-
return this.createSourceNode(statement, [
|
|
34
|
-
debugLineToInsert,
|
|
35
|
-
originalResult,
|
|
36
|
-
]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const plugin = {
|
|
40
|
-
printer: (program, emitHost, fileName, file) => new CustomPrinter(emitHost, program, fileName).print(file),
|
|
41
|
-
};
|
|
42
|
-
// ts-prune-ignore-next
|
|
43
|
-
exports.default = plugin;
|
|
44
|
-
//# sourceMappingURL=addCrashDebugStatements.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addCrashDebugStatements.js","sourceRoot":"","sources":["../../../src/plugins/addCrashDebugStatements.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAGjC,wDAA0C;AAE1C,MAAM,aAAc,SAAQ,IAAI,CAAC,UAAU;IACzC,cAAc,CAAC,SAAyB;QACtC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,iBAAiB,GAAG,kCAAkC,IAAI,MAAM,CAAC;QACvE,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE;YACtC,iBAAiB;YACjB,cAAc;SACf,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,MAAM,GAAgB;IAC1B,OAAO,EAAE,CACP,OAAmB,EACnB,QAAuB,EACvB,QAAgB,EAChB,IAAe,EACf,EAAE,CAAC,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;CAChE,CAAC;AAEF,uBAAuB;AACvB,kBAAe,MAAM,CAAC"}
|
package/src/monkeyPatch.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { MAIN_LUA } from "./constants";
|
|
3
|
-
import * as file from "./file";
|
|
4
|
-
|
|
5
|
-
const INFORMATIONAL_HEADER = `--[[
|
|
6
|
-
|
|
7
|
-
This Isaac mod was created with the IsaacScript tool.
|
|
8
|
-
|
|
9
|
-
The Lua code in this file was automatically generated from higher-level TypeScript code and might be
|
|
10
|
-
hard to read. If you want to understand how the code in this mod works, you should read the actual
|
|
11
|
-
TypeScript source code directly instead of trying to parse this file. Usually, the link to the
|
|
12
|
-
source code can be found in the mod's description on the Steam Workshop. If not, you can ask the mod
|
|
13
|
-
author directly if the source code is publicly available.
|
|
14
|
-
|
|
15
|
-
IsaacScript provides a lot of advantages over using raw Lua. For more information about the tool,
|
|
16
|
-
see the official website: https://isaacscript.github.io/
|
|
17
|
-
|
|
18
|
-
--]]
|
|
19
|
-
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
const MAIN_LUA_REPLACEMENTS = [
|
|
23
|
-
// For TSTL v1.2.X-v1.3.3
|
|
24
|
-
// (fixed with GlassBrick's PR)
|
|
25
|
-
["WeakMap = __TS__Class()", "WeakMap = WeakMap or __TS__Class()"],
|
|
26
|
-
["WeakSet = __TS__Class()", "WeakSet = WeakSet or __TS__Class()"],
|
|
27
|
-
["Map = __TS__Class()", "Map = Map or __TS__Class()"],
|
|
28
|
-
["Set = __TS__Class()", "Set = Set or __TS__Class()"],
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
-
function monkeyPatchMainLua(targetModDirectory: string, verbose: boolean) {
|
|
33
|
-
const mainLuaPath = path.join(targetModDirectory, MAIN_LUA);
|
|
34
|
-
const mainLua = file.read(mainLuaPath);
|
|
35
|
-
|
|
36
|
-
// mainLua = patchInformationalHeader(mainLua);
|
|
37
|
-
// mainLua = patchGlobalObjects(mainLua);
|
|
38
|
-
|
|
39
|
-
file.write(mainLuaPath, mainLua, verbose);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Add an informational header for people who happen to be browsing the Lua output
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
|
-
function patchInformationalHeader(mainLua: string) {
|
|
45
|
-
return INFORMATIONAL_HEADER + mainLua;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Some TSTL objects (such as Map and Set) are written as global variables,
|
|
49
|
-
// which can cause multiple mods written with IsaacScript to trample on one another
|
|
50
|
-
// Until TSTL has an official fix, monkey patch this
|
|
51
|
-
// We also make sure of this function to compose a stock comment header for curious people looking
|
|
52
|
-
// at the transpiled Lua code
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
54
|
-
function patchGlobalObjects(originalMainLua: string) {
|
|
55
|
-
let mainLua = originalMainLua;
|
|
56
|
-
|
|
57
|
-
for (const [findString, replaceString] of MAIN_LUA_REPLACEMENTS) {
|
|
58
|
-
mainLua = mainLua.replace(findString, replaceString);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return mainLua;
|
|
62
|
-
}
|