isaacscript 2.0.6 → 2.0.9
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 +12 -6
- package/dist/src/commands/init/createMod.js +9 -9
- package/dist/src/commands/init/git.js +3 -3
- package/dist/src/commands/init/init.js +2 -2
- package/dist/src/commands/monitor/monitor.js +9 -9
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +2 -2
- package/dist/src/configFile.js +1 -1
- package/dist/src/constants.js +12 -9
- package/dist/src/file.js +1 -1
- package/dist/src/main.js +3 -3
- package/dist/src/utils.js +5 -5
- package/dist/src/validateInIsaacScriptProject.js +1 -1
- package/package.json +12 -6
- package/.cspell.json +0 -25
- package/.eslintrc.js +0 -28
- package/.gitattributes +0 -9
- package/.github/workflows/ci.yml +0 -47
- package/.prettierignore +0 -5
- package/.prettierrc.js +0 -42
- package/.vscode/extensions.json +0 -9
- package/.vscode/settings.json +0 -75
- package/build.sh +0 -30
- package/check-file-updates.sh +0 -67
- package/check-file-updates.txt +0 -8
- package/check-gitignore.sh +0 -26
- package/check-orphaned-words.sh +0 -58
- package/dist/src/checkForWindowsTerminalBugs.js.map +0 -1
- package/dist/src/commands/copy/copy.js.map +0 -1
- package/dist/src/commands/init/checkIfProjectPathExists.js.map +0 -1
- package/dist/src/commands/init/checkModSubdirectory.js.map +0 -1
- package/dist/src/commands/init/checkModTargetDirectory.js.map +0 -1
- package/dist/src/commands/init/createMod.js.map +0 -1
- package/dist/src/commands/init/getModsDir.js.map +0 -1
- package/dist/src/commands/init/getProjectPath.js.map +0 -1
- package/dist/src/commands/init/git.js.map +0 -1
- package/dist/src/commands/init/init.js.map +0 -1
- package/dist/src/commands/init/installVSCodeExtensions.js.map +0 -1
- package/dist/src/commands/init/promptSaveSlot.js.map +0 -1
- package/dist/src/commands/init/promptVSCode.js.map +0 -1
- package/dist/src/commands/monitor/copyWatcherMod.js.map +0 -1
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +0 -1
- package/dist/src/commands/monitor/monitor.js.map +0 -1
- package/dist/src/commands/monitor/notifyGame.js.map +0 -1
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +0 -1
- package/dist/src/commands/monitor/saveDatWriter/types.js.map +0 -1
- package/dist/src/commands/monitor/spawnSaveDatWriter.js.map +0 -1
- package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +0 -1
- package/dist/src/commands/publish/publish.js.map +0 -1
- package/dist/src/configFile.js.map +0 -1
- package/dist/src/constants.js.map +0 -1
- package/dist/src/exec.js.map +0 -1
- package/dist/src/file.js.map +0 -1
- package/dist/src/main.js.map +0 -1
- package/dist/src/parseArgs.js.map +0 -1
- package/dist/src/prompt.js.map +0 -1
- package/dist/src/types/Command.js.map +0 -1
- package/dist/src/types/Config.js.map +0 -1
- package/dist/src/types/GitHubCLIHostsYAML.js.map +0 -1
- package/dist/src/utils.js.map +0 -1
- package/dist/src/validateInIsaacScriptProject.js.map +0 -1
- package/dist/src/validateNodeVersion.js.map +0 -1
- package/dist/src/validateOS.js.map +0 -1
- package/eslint-debug.sh +0 -11
- package/file-templates/dynamic/README.md +0 -3
- package/file-templates/dynamic/gitignore +0 -144
- package/file-templates/dynamic/main.ts +0 -19
- package/file-templates/dynamic/metadata.vdf +0 -6
- package/file-templates/dynamic/metadata.xml +0 -8
- package/file-templates/dynamic/package.json +0 -20
- package/file-templates/static/.cspell.json.template +0 -21
- package/file-templates/static/.env_template +0 -2
- package/file-templates/static/.eslintrc.js +0 -24
- package/file-templates/static/.gitattributes +0 -9
- package/file-templates/static/.github/workflows/ci.yml +0 -53
- package/file-templates/static/.prettierignore +0 -14
- package/file-templates/static/.prettierrc.js +0 -42
- package/file-templates/static/.vscode/extensions.json +0 -10
- package/file-templates/static/.vscode/settings.json +0 -75
- package/file-templates/static/LICENSE +0 -674
- package/file-templates/static/build.sh +0 -15
- package/file-templates/static/check-orphaned-words.sh +0 -58
- package/file-templates/static/lint.sh +0 -39
- package/file-templates/static/nuke.sh +0 -18
- package/file-templates/static/plugins/addCrashDebugStatements.ts +0 -40
- package/file-templates/static/plugins/addIsaacScriptCommentHeader.ts +0 -37
- package/file-templates/static/plugins/noExtendedEnums.ts +0 -66
- package/file-templates/static/publish.sh +0 -10
- package/file-templates/static/run.sh +0 -10
- package/file-templates/static/src/bundleEntry.ts +0 -10
- package/file-templates/static/tsconfig.eslint.json +0 -11
- package/file-templates/static/tsconfig.json +0 -33
- package/file-templates/static/update.sh +0 -21
- package/file-templates/static-alt/.prettierignore-base +0 -5
- package/file-templates/static-alt/.prettierrc-base.js +0 -30
- package/file-templates/static-alt/.vscode/extensions-format.json +0 -8
- package/file-templates/static-alt/.vscode/extensions-typescript.json +0 -9
- package/file-templates/static-alt/.vscode/settings-typescript.json +0 -63
- package/file-templates/static-alt/check-file-updates.sh +0 -67
- package/lint.sh +0 -38
- package/misc/logo.png +0 -0
- package/misc/mouseover.png +0 -0
- package/nuke.sh +0 -18
- package/publish.sh +0 -11
- package/src/checkForWindowsTerminalBugs.ts +0 -106
- package/src/commands/copy/copy.ts +0 -41
- package/src/commands/init/checkIfProjectPathExists.ts +0 -34
- package/src/commands/init/checkModSubdirectory.ts +0 -20
- package/src/commands/init/checkModTargetDirectory.ts +0 -42
- package/src/commands/init/createMod.ts +0 -196
- package/src/commands/init/getModsDir.ts +0 -107
- package/src/commands/init/getProjectPath.ts +0 -111
- package/src/commands/init/git.ts +0 -249
- package/src/commands/init/init.ts +0 -93
- package/src/commands/init/installVSCodeExtensions.ts +0 -47
- package/src/commands/init/promptSaveSlot.ts +0 -27
- package/src/commands/init/promptVSCode.ts +0 -33
- package/src/commands/monitor/copyWatcherMod.ts +0 -54
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +0 -67
- package/src/commands/monitor/monitor.ts +0 -180
- package/src/commands/monitor/notifyGame.ts +0 -59
- package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +0 -145
- package/src/commands/monitor/saveDatWriter/types.ts +0 -6
- package/src/commands/monitor/spawnSaveDatWriter.ts +0 -36
- package/src/commands/monitor/touchWatcherSaveDatFiles.ts +0 -20
- package/src/commands/publish/publish.ts +0 -392
- package/src/configFile.ts +0 -80
- package/src/constants.ts +0 -85
- package/src/exec.ts +0 -125
- package/src/file.ts +0 -235
- package/src/main.ts +0 -131
- package/src/parseArgs.ts +0 -127
- package/src/prompt.ts +0 -109
- package/src/types/Command.ts +0 -3
- package/src/types/Config.ts +0 -23
- package/src/types/GitHubCLIHostsYAML.ts +0 -7
- package/src/utils.ts +0 -92
- package/src/validateInIsaacScriptProject.ts +0 -35
- package/src/validateNodeVersion.ts +0 -29
- package/src/validateOS.ts +0 -20
- package/tsconfig.eslint.json +0 -11
- package/tsconfig.json +0 -21
- package/update.sh +0 -21
package/src/commands/init/git.ts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
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
|
-
yes: boolean,
|
|
18
|
-
verbose: boolean,
|
|
19
|
-
): Promise<string | undefined> {
|
|
20
|
-
// We do not need to prompt the user if they do not have Git installed
|
|
21
|
-
if (!commandExists.sync("git")) {
|
|
22
|
-
console.log(
|
|
23
|
-
'Git does not seem to be installed. (The "git" command is not in the path.) Skipping Git-related things.',
|
|
24
|
-
);
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
validateNewGitVersion(verbose);
|
|
29
|
-
|
|
30
|
-
const gitHubUsername = getGitHubUsername(verbose);
|
|
31
|
-
if (gitHubUsername !== undefined) {
|
|
32
|
-
const [exitStatus] = execShell(
|
|
33
|
-
"gh",
|
|
34
|
-
["repo", "view", projectName],
|
|
35
|
-
verbose,
|
|
36
|
-
true,
|
|
37
|
-
);
|
|
38
|
-
const gitHubRepoExists = exitStatus === 0;
|
|
39
|
-
const url = `https://github.com/${gitHubUsername}/${projectName}`;
|
|
40
|
-
|
|
41
|
-
if (gitHubRepoExists) {
|
|
42
|
-
console.log(
|
|
43
|
-
`Detected an existing GitHub repository at: ${chalk.green(url)}`,
|
|
44
|
-
);
|
|
45
|
-
const guessedRemoteURL = getGitRemoteURL(projectName, gitHubUsername);
|
|
46
|
-
|
|
47
|
-
if (yes) {
|
|
48
|
-
console.log(
|
|
49
|
-
`Using a Git remote URL of: ${chalk.green(guessedRemoteURL)}`,
|
|
50
|
-
);
|
|
51
|
-
return guessedRemoteURL;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const shouldUseGuessedURL = await getInputYesNo(
|
|
55
|
-
`Do you want to use a Git remote URL of: ${chalk.green(
|
|
56
|
-
guessedRemoteURL,
|
|
57
|
-
)}`,
|
|
58
|
-
);
|
|
59
|
-
if (shouldUseGuessedURL) {
|
|
60
|
-
return guessedRemoteURL;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Assume that since they do not want to connect this project to the existing GitHub
|
|
64
|
-
// repository, they do not want to initialize a remote Git URL at all.
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (yes) {
|
|
69
|
-
execShell("gh", ["repo", "create", projectName, "--public"]);
|
|
70
|
-
console.log(`Created a new GitHub repository at: ${chalk.green(url)}`);
|
|
71
|
-
return getGitRemoteURL(projectName, gitHubUsername);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const createNewGitHubRepo = await getInputYesNo(
|
|
75
|
-
`Would you like to create a new GitHub repository at: ${chalk.green(
|
|
76
|
-
url,
|
|
77
|
-
)}`,
|
|
78
|
-
);
|
|
79
|
-
if (createNewGitHubRepo) {
|
|
80
|
-
execShell("gh", ["repo", "create", projectName, "--public"]);
|
|
81
|
-
console.log("Successfully created a new GitHub repository.");
|
|
82
|
-
return getGitRemoteURL(projectName, gitHubUsername);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Assume that since they do not want to create a new GitHub repository, they do not want to
|
|
86
|
-
// initialize a remote Git URL at all.
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const gitRemoteURL =
|
|
91
|
-
await getInputString(`Paste in the remote Git URL for your project.
|
|
92
|
-
For example, if you have an SSH key, it would be something like:
|
|
93
|
-
${chalk.green("git@github.com:Alice/green-candle.git")}
|
|
94
|
-
If you don't have an SSH key, it would be something like:
|
|
95
|
-
${chalk.green("https://github.com/Alice/green-candle.git")}
|
|
96
|
-
If you don't want to initialize a Git repository for this project, press enter to skip.
|
|
97
|
-
`);
|
|
98
|
-
|
|
99
|
-
return gitRemoteURL === "" ? undefined : gitRemoteURL;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function validateNewGitVersion(verbose: boolean) {
|
|
103
|
-
const [, stdout] = execShell("git", ["--version"], verbose);
|
|
104
|
-
|
|
105
|
-
const outputPrefix = "git version ";
|
|
106
|
-
if (!stdout.startsWith(outputPrefix)) {
|
|
107
|
-
error(
|
|
108
|
-
`Failed to parse the output from the "git --version" command: ${stdout}`,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const gitVersionString = stdout.slice(outputPrefix.length);
|
|
113
|
-
const [majorVersion, minorVersion] = parseSemVer(gitVersionString);
|
|
114
|
-
|
|
115
|
-
if (
|
|
116
|
-
majorVersion >= REQUIRED_GIT_MAJOR_VERSION &&
|
|
117
|
-
minorVersion >= REQUIRED_GIT_MINOR_VERSION
|
|
118
|
-
) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
console.error(`Your Git version is: ${chalk.red(gitVersionString)}`);
|
|
123
|
-
console.error(
|
|
124
|
-
`${PROJECT_NAME} requires a Git version of ${chalk.red(
|
|
125
|
-
`${REQUIRED_GIT_MAJOR_VERSION}.${REQUIRED_GIT_MINOR_VERSION}.0`,
|
|
126
|
-
)} or greater.`,
|
|
127
|
-
);
|
|
128
|
-
console.error(
|
|
129
|
-
`Please upgrade your version of Git before using ${PROJECT_NAME}.`,
|
|
130
|
-
);
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function getGitHubUsername(verbose: boolean) {
|
|
135
|
-
// If the GitHub CLI is installed, we can derive the user's GitHub username
|
|
136
|
-
if (!commandExists.sync("gh")) {
|
|
137
|
-
return undefined;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const appData = process.env["APPDATA"];
|
|
141
|
-
if (appData === undefined || appData === "") {
|
|
142
|
-
return undefined;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const githubCLIHostsPath = path.join(appData, "GitHub CLI", "hosts.yml");
|
|
146
|
-
if (!file.exists(githubCLIHostsPath, verbose)) {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const configYAMLRaw = file.read(githubCLIHostsPath, verbose);
|
|
151
|
-
const configYAML = yaml.parse(configYAMLRaw) as GitHubCLIHostsYAML;
|
|
152
|
-
|
|
153
|
-
const githubCom = configYAML["github.com"];
|
|
154
|
-
if (githubCom === undefined) {
|
|
155
|
-
return undefined;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const { user } = githubCom;
|
|
159
|
-
if (user === undefined || user === "") {
|
|
160
|
-
return undefined;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return user;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function getGitRemoteURL(projectName: string, gitHubUsername: string) {
|
|
167
|
-
return `git@github.com:${gitHubUsername}/${projectName}.git`;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export function initGitRepository(
|
|
171
|
-
projectPath: string,
|
|
172
|
-
gitRemoteURL: string | undefined,
|
|
173
|
-
verbose: boolean,
|
|
174
|
-
): void {
|
|
175
|
-
if (!commandExists.sync("git")) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (gitRemoteURL === undefined) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
execShell("git", ["init"], verbose, false, projectPath);
|
|
184
|
-
execShell("git", ["branch", "-M", "main"], verbose, false, projectPath);
|
|
185
|
-
|
|
186
|
-
if (isGitNameAndEmailConfigured(verbose)) {
|
|
187
|
-
execShell("git", ["add", "--all"], verbose, false, projectPath);
|
|
188
|
-
execShell(
|
|
189
|
-
"git",
|
|
190
|
-
["commit", "--message", `${PROJECT_NAME} template`],
|
|
191
|
-
verbose,
|
|
192
|
-
false,
|
|
193
|
-
projectPath,
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (gitRemoteURL !== undefined) {
|
|
198
|
-
execShell(
|
|
199
|
-
"git",
|
|
200
|
-
["remote", "add", "origin", gitRemoteURL],
|
|
201
|
-
verbose,
|
|
202
|
-
false,
|
|
203
|
-
projectPath,
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function isGitNameAndEmailConfigured(verbose: boolean) {
|
|
209
|
-
const [nameExitStatus] = execShell(
|
|
210
|
-
"git",
|
|
211
|
-
["config", "--global", "user.name"],
|
|
212
|
-
verbose,
|
|
213
|
-
true,
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
const [emailExitStatus] = execShell(
|
|
217
|
-
"git",
|
|
218
|
-
["config", "--global", "user.email"],
|
|
219
|
-
verbose,
|
|
220
|
-
true,
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
return nameExitStatus === 0 && emailExitStatus === 0;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export function isGitDirty(verbose: boolean): boolean {
|
|
227
|
-
// From: https://remarkablemark.org/blog/2017/10/12/check-git-dirty/
|
|
228
|
-
const [, stdout] = execShell("git", ["status", "--porcelain"], verbose);
|
|
229
|
-
return stdout !== "";
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export function gitCommitIfChanges(version: string, verbose: boolean): void {
|
|
233
|
-
// Throw an error if this is not a git repository
|
|
234
|
-
execShell("git", ["status"], verbose);
|
|
235
|
-
|
|
236
|
-
if (!isGitDirty(verbose)) {
|
|
237
|
-
console.log("There are no changes to commit.");
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const commitMessage = `v${version}`;
|
|
242
|
-
execShell("git", ["add", "-A"], verbose);
|
|
243
|
-
execShell("git", ["commit", "-m", commitMessage], verbose);
|
|
244
|
-
execShell("git", ["push"], verbose);
|
|
245
|
-
|
|
246
|
-
console.log(
|
|
247
|
-
`Committed and pushed to the git repository with a message of: ${commitMessage}`,
|
|
248
|
-
);
|
|
249
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import commandExists from "command-exists";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { CWD, PROJECT_NAME } from "../../constants";
|
|
5
|
-
import { checkIfProjectPathExists } from "./checkIfProjectPathExists";
|
|
6
|
-
import { checkModSubdirectory } from "./checkModSubdirectory";
|
|
7
|
-
import { checkModTargetDirectory } from "./checkModTargetDirectory";
|
|
8
|
-
import { createMod } from "./createMod";
|
|
9
|
-
import { getModsDir } from "./getModsDir";
|
|
10
|
-
import { getProjectPath } from "./getProjectPath";
|
|
11
|
-
import { promptGitHubRepoOrGitRemoteURL } from "./git";
|
|
12
|
-
import { installVSCodeExtensions } from "./installVSCodeExtensions";
|
|
13
|
-
import { promptSaveSlot } from "./promptSaveSlot";
|
|
14
|
-
import { promptVSCode } from "./promptVSCode";
|
|
15
|
-
|
|
16
|
-
export async function init(argv: Record<string, unknown>): Promise<void> {
|
|
17
|
-
const skipNPMInstall = argv["skipNpmInstall"] === true;
|
|
18
|
-
const useCurrentDir = argv["useCurrentDir"] === true;
|
|
19
|
-
const verbose = argv["verbose"] === true;
|
|
20
|
-
const vscode = argv["vscode"] === true;
|
|
21
|
-
const yes = argv["yes"] === true;
|
|
22
|
-
const forceName = argv["forceName"] === true;
|
|
23
|
-
|
|
24
|
-
// Prompt the end-user for some information (and validate it as we go)
|
|
25
|
-
const [projectPath, createNewDir] = await getProjectPath(
|
|
26
|
-
argv,
|
|
27
|
-
useCurrentDir,
|
|
28
|
-
yes,
|
|
29
|
-
forceName,
|
|
30
|
-
);
|
|
31
|
-
await checkIfProjectPathExists(projectPath, yes, verbose);
|
|
32
|
-
const modsDirectory = await getModsDir(argv, verbose);
|
|
33
|
-
checkModSubdirectory(projectPath, modsDirectory);
|
|
34
|
-
const projectName = path.basename(projectPath);
|
|
35
|
-
await checkModTargetDirectory(modsDirectory, projectName, yes, verbose);
|
|
36
|
-
const saveSlot = await promptSaveSlot(argv, yes);
|
|
37
|
-
const gitRemoteURL = await promptGitHubRepoOrGitRemoteURL(
|
|
38
|
-
projectName,
|
|
39
|
-
yes,
|
|
40
|
-
verbose,
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
// Now that we have asked the user all of the questions we need, we can create the project
|
|
44
|
-
createMod(
|
|
45
|
-
projectName,
|
|
46
|
-
projectPath,
|
|
47
|
-
createNewDir,
|
|
48
|
-
modsDirectory,
|
|
49
|
-
saveSlot,
|
|
50
|
-
gitRemoteURL,
|
|
51
|
-
skipNPMInstall,
|
|
52
|
-
verbose,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
await openVSCode(projectPath, vscode, verbose);
|
|
56
|
-
printFinishMessage(projectPath, projectName);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function openVSCode(
|
|
60
|
-
projectPath: string,
|
|
61
|
-
vscode: boolean,
|
|
62
|
-
verbose: boolean,
|
|
63
|
-
) {
|
|
64
|
-
const VSCodeCommand = getVSCodeCommand();
|
|
65
|
-
if (VSCodeCommand === null) {
|
|
66
|
-
console.log(
|
|
67
|
-
'VSCode does not seem to be installed. (The "code" command is not in the path.) Skipping VSCode-related things.',
|
|
68
|
-
);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
installVSCodeExtensions(projectPath, VSCodeCommand, verbose);
|
|
73
|
-
await promptVSCode(projectPath, VSCodeCommand, vscode, verbose);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function getVSCodeCommand() {
|
|
77
|
-
for (const VSCodeCommand of ["code", "codium", "code-oss", "code-insiders"]) {
|
|
78
|
-
if (commandExists.sync(VSCodeCommand)) {
|
|
79
|
-
return VSCodeCommand;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function printFinishMessage(projectPath: string, projectName: string) {
|
|
87
|
-
let commandsToType = "";
|
|
88
|
-
if (projectPath !== CWD) {
|
|
89
|
-
commandsToType += `"${chalk.green(`cd ${projectName}`)}" and `;
|
|
90
|
-
}
|
|
91
|
-
commandsToType += `"${chalk.green("npx isaacscript")}"`;
|
|
92
|
-
console.log(`Now, start ${PROJECT_NAME} by typing ${commandsToType}.`);
|
|
93
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import * as JSONC from "jsonc-parser";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { execShell } from "../../exec";
|
|
5
|
-
import * as file from "../../file";
|
|
6
|
-
import { error } from "../../utils";
|
|
7
|
-
|
|
8
|
-
export function installVSCodeExtensions(
|
|
9
|
-
projectPath: string,
|
|
10
|
-
VSCodeCommand: string,
|
|
11
|
-
verbose: boolean,
|
|
12
|
-
): void {
|
|
13
|
-
const extensions = getExtensionsFromJSON(projectPath, verbose);
|
|
14
|
-
for (const extensionName of extensions) {
|
|
15
|
-
execShell(VSCodeCommand, ["--install-extension", extensionName], verbose);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface ExtensionsJSON {
|
|
20
|
-
recommendations: string[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getExtensionsFromJSON(projectPath: string, verbose: boolean) {
|
|
24
|
-
const extensionsJSONPath = path.join(
|
|
25
|
-
projectPath,
|
|
26
|
-
".vscode",
|
|
27
|
-
"extensions.json",
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
if (!file.exists(extensionsJSONPath, verbose)) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const extensionsJSONRaw = file.read(extensionsJSONPath, verbose);
|
|
35
|
-
|
|
36
|
-
let extensionsJSON: ExtensionsJSON;
|
|
37
|
-
try {
|
|
38
|
-
extensionsJSON = JSONC.parse(extensionsJSONRaw) as ExtensionsJSON;
|
|
39
|
-
} catch (err) {
|
|
40
|
-
error(
|
|
41
|
-
`Failed to parse the "${chalk.green(extensionsJSONPath)}" file:`,
|
|
42
|
-
err,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return extensionsJSON.recommendations;
|
|
47
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { getInputInt } from "../../prompt";
|
|
2
|
-
import { error } from "../../utils";
|
|
3
|
-
|
|
4
|
-
export async function promptSaveSlot(
|
|
5
|
-
argv: Record<string, unknown>,
|
|
6
|
-
yes: boolean,
|
|
7
|
-
): Promise<number> {
|
|
8
|
-
if (argv["saveSlot"] !== undefined) {
|
|
9
|
-
// They specified the "--save-slot" command-line flag, so there is no need to prompt the user
|
|
10
|
-
// for it.
|
|
11
|
-
return argv["saveSlot"] as number; // yargs converts this to a number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (yes) {
|
|
15
|
-
return 1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const saveSlot = await getInputInt(
|
|
19
|
-
"In-game, will you test your mod on save slot 1, 2, or 3?",
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
if (saveSlot !== 1 && saveSlot !== 2 && saveSlot !== 3) {
|
|
23
|
-
error("Error: You must choose a number between 1 and 3.");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return saveSlot;
|
|
27
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { MAIN_TS } from "../../constants";
|
|
3
|
-
import { execShell } from "../../exec";
|
|
4
|
-
import { getInputYesNo } from "../../prompt";
|
|
5
|
-
|
|
6
|
-
export async function promptVSCode(
|
|
7
|
-
projectPath: string,
|
|
8
|
-
VSCodeCommand: string,
|
|
9
|
-
vscode: boolean,
|
|
10
|
-
verbose: boolean,
|
|
11
|
-
): Promise<void> {
|
|
12
|
-
if (vscode) {
|
|
13
|
-
// They supplied the "--vscode" command-line flag, so there is no need to prompt the user.
|
|
14
|
-
openVSCode(projectPath, VSCodeCommand, verbose);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const shouldOpenVSCode = await getInputYesNo(
|
|
19
|
-
"Do you want to open your new project in VSCode now?",
|
|
20
|
-
);
|
|
21
|
-
if (shouldOpenVSCode) {
|
|
22
|
-
openVSCode(projectPath, VSCodeCommand, verbose);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function openVSCode(
|
|
27
|
-
projectPath: string,
|
|
28
|
-
VSCodeCommand: string,
|
|
29
|
-
verbose: boolean,
|
|
30
|
-
) {
|
|
31
|
-
const MAIN_TS_PATH = path.join(projectPath, "src", MAIN_TS);
|
|
32
|
-
execShell(VSCodeCommand, [projectPath, MAIN_TS_PATH], verbose);
|
|
33
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import {
|
|
3
|
-
DISABLE_IT_FILE,
|
|
4
|
-
MAIN_LUA,
|
|
5
|
-
WATCHER_MOD_NAME,
|
|
6
|
-
WATCHER_MOD_SOURCE_PATH,
|
|
7
|
-
} from "../../constants";
|
|
8
|
-
import * as file from "../../file";
|
|
9
|
-
import { Config } from "../../types/Config";
|
|
10
|
-
|
|
11
|
-
export function copyWatcherMod(config: Config, verbose: boolean): void {
|
|
12
|
-
// Check to see if this mod was disabled.
|
|
13
|
-
const watcherModPath = path.join(config.modsDirectory, WATCHER_MOD_NAME);
|
|
14
|
-
const disableItPath = path.join(watcherModPath, DISABLE_IT_FILE);
|
|
15
|
-
const watcherModDisabled = file.exists(disableItPath, verbose);
|
|
16
|
-
|
|
17
|
-
// Delete and re-copy the watcher mod every time IsaacScript starts. This ensures that it is
|
|
18
|
-
// always the latest version.
|
|
19
|
-
if (file.exists(watcherModPath, verbose)) {
|
|
20
|
-
file.deleteFileOrDirectory(watcherModPath, verbose);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
file.copy(WATCHER_MOD_SOURCE_PATH, watcherModPath, verbose);
|
|
24
|
-
|
|
25
|
-
if (watcherModDisabled) {
|
|
26
|
-
// Since we deleted the directory, the "disable.it" file was deleted. Restore it.
|
|
27
|
-
file.write(disableItPath, "", verbose);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// By default, the IsaacScript watcher mod automatically restarts the game, so we only need to
|
|
31
|
-
// disable it if the config option is explicitly set to false.
|
|
32
|
-
if (config.enableIsaacScriptWatcherAutoRestart === false) {
|
|
33
|
-
disableIsaacScriptWatcherAutomaticRestart(watcherModPath, verbose);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// If we copied a new version of the watcher mod into place, but the user currently has the game
|
|
37
|
-
// open, then the old version will stay loaded. However, if the watcher mod reloads itself, the
|
|
38
|
-
// game will crash, so there is no automated solution for this.
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function disableIsaacScriptWatcherAutomaticRestart(
|
|
42
|
-
watcherModPath: string,
|
|
43
|
-
verbose: boolean,
|
|
44
|
-
) {
|
|
45
|
-
const mainLuaPath = path.join(watcherModPath, MAIN_LUA);
|
|
46
|
-
const mainLua = file.read(mainLuaPath, verbose);
|
|
47
|
-
|
|
48
|
-
const modifiedMainLua = mainLua.replace(
|
|
49
|
-
"local RESTART_GAME_ON_RECOMPILATION = true",
|
|
50
|
-
"local RESTART_GAME_ON_RECOMPILATION = false",
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
file.write(mainLuaPath, modifiedMainLua, verbose);
|
|
54
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import syncDirectory from "sync-directory";
|
|
2
|
-
import { FILE_SYNCED_MESSAGE } from "../../../constants";
|
|
3
|
-
|
|
4
|
-
const SUBPROCESS_NAME = "directory syncer";
|
|
5
|
-
const BASE_ARGV_LENGTH = 2;
|
|
6
|
-
|
|
7
|
-
let modSourcePath: string;
|
|
8
|
-
let modTargetPath: string;
|
|
9
|
-
|
|
10
|
-
init();
|
|
11
|
-
|
|
12
|
-
function init() {
|
|
13
|
-
const firstArg = process.argv[BASE_ARGV_LENGTH];
|
|
14
|
-
if (firstArg === undefined) {
|
|
15
|
-
throw new Error(
|
|
16
|
-
`The ${SUBPROCESS_NAME} process did not get a valid first argument.`,
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const secondArg = process.argv[BASE_ARGV_LENGTH + 1];
|
|
21
|
-
if (secondArg === undefined) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
`The ${SUBPROCESS_NAME} process did not get the right amount of arguments.`,
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
modSourcePath = firstArg;
|
|
28
|
-
modTargetPath = secondArg;
|
|
29
|
-
|
|
30
|
-
syncDirectory(modSourcePath, modTargetPath, {
|
|
31
|
-
watch: true,
|
|
32
|
-
type: "copy",
|
|
33
|
-
afterEachSync,
|
|
34
|
-
onError,
|
|
35
|
-
chokidarWatchOptions: {
|
|
36
|
-
awaitWriteFinish: {
|
|
37
|
-
stabilityThreshold: 1000,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function afterEachSync(params?: {
|
|
44
|
-
eventType: string;
|
|
45
|
-
nodeType: string;
|
|
46
|
-
relativePath: string;
|
|
47
|
-
srcPath: string;
|
|
48
|
-
targetPath: string;
|
|
49
|
-
}) {
|
|
50
|
-
if (params === undefined) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (params.eventType !== "init:copy") {
|
|
55
|
-
send(`${FILE_SYNCED_MESSAGE} ${params.relativePath}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function onError(err: Error) {
|
|
60
|
-
send(`The directory syncer encountered an error: ${err}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function send(msg: string) {
|
|
64
|
-
if (process.send !== undefined) {
|
|
65
|
-
process.send(msg);
|
|
66
|
-
}
|
|
67
|
-
}
|