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/file.ts
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { error } from "./utils";
|
|
5
|
-
|
|
6
|
-
export function copy(srcPath: string, dstPath: string, verbose: boolean): void {
|
|
7
|
-
if (verbose) {
|
|
8
|
-
console.log(`Copying: ${srcPath} --> ${dstPath}`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
// "copySync()" is a "fs-extra" method for copying directories recursively
|
|
13
|
-
fs.copySync(srcPath, dstPath, {
|
|
14
|
-
recursive: true,
|
|
15
|
-
});
|
|
16
|
-
} catch (err) {
|
|
17
|
-
error(
|
|
18
|
-
`Failed to copy directory "${chalk.green(srcPath)}" to "${chalk.green(
|
|
19
|
-
dstPath,
|
|
20
|
-
)}":`,
|
|
21
|
-
err,
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (verbose) {
|
|
26
|
-
console.log(`Copied: ${srcPath} --> ${dstPath}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function deleteFileOrDirectory(
|
|
31
|
-
filePath: string,
|
|
32
|
-
verbose: boolean,
|
|
33
|
-
): void {
|
|
34
|
-
if (verbose) {
|
|
35
|
-
console.log(`Deleting: ${filePath}`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
fs.rmSync(filePath, {
|
|
40
|
-
recursive: true,
|
|
41
|
-
});
|
|
42
|
-
} catch (err) {
|
|
43
|
-
error(
|
|
44
|
-
`Failed to delete file or directory "${chalk.green(filePath)}":`,
|
|
45
|
-
err,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (verbose) {
|
|
50
|
-
console.log(`Deleted: ${filePath}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function exists(filePath: string, verbose: boolean): boolean {
|
|
55
|
-
if (verbose) {
|
|
56
|
-
console.log(`Checking to see if the following path exists: ${filePath}`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let pathExists: boolean;
|
|
60
|
-
try {
|
|
61
|
-
pathExists = fs.existsSync(filePath);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
error(`Failed to check if "${chalk.green(filePath)}" exists:`, err);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (verbose) {
|
|
67
|
-
console.log(`Path exists: ${pathExists}`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return pathExists;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function getDirList(dirPath: string, verbose: boolean): string[] {
|
|
74
|
-
if (verbose) {
|
|
75
|
-
console.log(`Getting a directory list from: ${dirPath}`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let fileList: string[];
|
|
79
|
-
try {
|
|
80
|
-
fileList = fs.readdirSync(dirPath);
|
|
81
|
-
} catch (err) {
|
|
82
|
-
error(
|
|
83
|
-
`Failed to get the files in the "${chalk.green(dirPath)}" directory:`,
|
|
84
|
-
err,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (verbose) {
|
|
89
|
-
console.log(`Got a directory list from: ${dirPath}`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return fileList;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function getFileStats(filePath: string, verbose: boolean): fs.Stats {
|
|
96
|
-
if (verbose) {
|
|
97
|
-
console.log(`Getting file stats from: ${filePath}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let fileStats: fs.Stats;
|
|
101
|
-
try {
|
|
102
|
-
fileStats = fs.statSync(filePath);
|
|
103
|
-
} catch (err) {
|
|
104
|
-
error(`Failed to get the file stats for "${chalk.green(filePath)}":`, err);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (verbose) {
|
|
108
|
-
console.log(`Got file stats from: ${filePath}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return fileStats;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function isDir(filePath: string, verbose: boolean): boolean {
|
|
115
|
-
const fileStats = getFileStats(filePath, verbose);
|
|
116
|
-
return fileStats.isDirectory();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function isSubDirOf(dir: string, parent: string): boolean {
|
|
120
|
-
const relative = path.relative(parent, dir);
|
|
121
|
-
return (
|
|
122
|
-
relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative)
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function makeDir(dirPath: string, verbose: boolean): void {
|
|
127
|
-
if (verbose) {
|
|
128
|
-
console.log(`Making a directory: ${dirPath}`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
fs.mkdirSync(dirPath, {
|
|
133
|
-
recursive: true,
|
|
134
|
-
});
|
|
135
|
-
} catch (err) {
|
|
136
|
-
error(`Failed to create the "${chalk.green(dirPath)}" directory:`, err);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (verbose) {
|
|
140
|
-
console.log(`Made a directory: ${dirPath}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function read(filePath: string, verbose: boolean): string {
|
|
145
|
-
if (verbose) {
|
|
146
|
-
console.log(`Reading a file: ${filePath}`);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
let fileContents: string;
|
|
150
|
-
try {
|
|
151
|
-
fileContents = fs.readFileSync(filePath, "utf8");
|
|
152
|
-
} catch (err) {
|
|
153
|
-
error(`Failed to read the "${chalk.green(filePath)}" file:`, err);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (verbose) {
|
|
157
|
-
console.log(`Read a file: ${filePath}`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return fileContents;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export function rename(
|
|
164
|
-
srcPath: string,
|
|
165
|
-
dstPath: string,
|
|
166
|
-
verbose: boolean,
|
|
167
|
-
): void {
|
|
168
|
-
if (verbose) {
|
|
169
|
-
console.log(`Renaming: ${srcPath} --> ${dstPath}`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
fs.renameSync(srcPath, dstPath);
|
|
174
|
-
} catch (err) {
|
|
175
|
-
error(
|
|
176
|
-
`Failed to rename "${chalk.green(srcPath)}" to "${chalk.green(
|
|
177
|
-
dstPath,
|
|
178
|
-
)}":`,
|
|
179
|
-
err,
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (verbose) {
|
|
184
|
-
console.log(`Renamed: ${srcPath} --> ${dstPath}`);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export function touch(filePath: string, verbose: boolean): void {
|
|
189
|
-
if (verbose) {
|
|
190
|
-
console.log(`Touching: ${filePath}`);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
const fileHandle = fs.openSync(filePath, "w");
|
|
195
|
-
fs.closeSync(fileHandle);
|
|
196
|
-
} catch (err) {
|
|
197
|
-
error(`Failed to touch the "${chalk.green(filePath)}" file:`, err);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (verbose) {
|
|
201
|
-
console.log(`Touched: ${filePath}`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export function write(filePath: string, data: string, verbose: boolean): void {
|
|
206
|
-
if (verbose) {
|
|
207
|
-
console.log(`Writing data to: ${filePath}`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
try {
|
|
211
|
-
fs.writeFileSync(filePath, data);
|
|
212
|
-
} catch (err) {
|
|
213
|
-
error(`Failed to write to the "${chalk.green(filePath)}" file:`, err);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (verbose) {
|
|
217
|
-
console.log(`Wrote data to: ${filePath}`);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export function writeTry(
|
|
222
|
-
filePath: string,
|
|
223
|
-
data: string,
|
|
224
|
-
verbose: boolean,
|
|
225
|
-
): void {
|
|
226
|
-
if (verbose) {
|
|
227
|
-
console.log(`Writing data to: ${filePath}`);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
fs.writeFileSync(filePath, data);
|
|
231
|
-
|
|
232
|
-
if (verbose) {
|
|
233
|
-
console.log(`Wrote data to: ${filePath}`);
|
|
234
|
-
}
|
|
235
|
-
}
|
package/src/main.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import * as dotenv from "dotenv";
|
|
5
|
-
import figlet from "figlet";
|
|
6
|
-
import path from "path";
|
|
7
|
-
import sourceMapSupport from "source-map-support";
|
|
8
|
-
import updateNotifier from "update-notifier";
|
|
9
|
-
import pkg from "../package.json";
|
|
10
|
-
import { checkForWindowsTerminalBugs } from "./checkForWindowsTerminalBugs";
|
|
11
|
-
import { copy } from "./commands/copy/copy";
|
|
12
|
-
import { init } from "./commands/init/init";
|
|
13
|
-
import { monitor } from "./commands/monitor/monitor";
|
|
14
|
-
import { publish } from "./commands/publish/publish";
|
|
15
|
-
import * as configFile from "./configFile";
|
|
16
|
-
import { CWD, PROJECT_NAME, YARN_LOCK_PATH } from "./constants";
|
|
17
|
-
import { execShell } from "./exec";
|
|
18
|
-
import * as file from "./file";
|
|
19
|
-
import { parseArgs } from "./parseArgs";
|
|
20
|
-
import { promptInit } from "./prompt";
|
|
21
|
-
import { Command, DEFAULT_COMMAND } from "./types/Command";
|
|
22
|
-
import { Config } from "./types/Config";
|
|
23
|
-
import { ensureAllCases, error } from "./utils";
|
|
24
|
-
import { validateInIsaacScriptProject } from "./validateInIsaacScriptProject";
|
|
25
|
-
import { validateNodeVersion } from "./validateNodeVersion";
|
|
26
|
-
import { validateOS } from "./validateOS";
|
|
27
|
-
|
|
28
|
-
main().catch((err) => {
|
|
29
|
-
error(`${PROJECT_NAME} failed:`, err);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
async function main(): Promise<void> {
|
|
33
|
-
sourceMapSupport.install();
|
|
34
|
-
promptInit();
|
|
35
|
-
validateNodeVersion();
|
|
36
|
-
validateOS();
|
|
37
|
-
loadEnvironmentVariables();
|
|
38
|
-
|
|
39
|
-
// Get command line arguments
|
|
40
|
-
const argv = parseArgs();
|
|
41
|
-
const verbose = argv["verbose"] === true;
|
|
42
|
-
|
|
43
|
-
printBanner();
|
|
44
|
-
|
|
45
|
-
// Check for a new version
|
|
46
|
-
updateNotifier({ pkg }).notify();
|
|
47
|
-
|
|
48
|
-
// Pre-flight checks
|
|
49
|
-
await checkForWindowsTerminalBugs(verbose);
|
|
50
|
-
|
|
51
|
-
await handleCommands(argv, verbose);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function loadEnvironmentVariables() {
|
|
55
|
-
const envFile = path.join(CWD, ".env");
|
|
56
|
-
dotenv.config({ path: envFile });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function printBanner() {
|
|
60
|
-
console.log(chalk.green(figlet.textSync(PROJECT_NAME)));
|
|
61
|
-
const bannerLength = 55; // From measuring the banner created by Figlet
|
|
62
|
-
const version = `v${pkg.version}`;
|
|
63
|
-
const leftPaddingAmount = Math.floor((bannerLength + version.length) / 2);
|
|
64
|
-
console.log(version.padStart(leftPaddingAmount));
|
|
65
|
-
console.log();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function handleCommands(argv: Record<string, unknown>, verbose: boolean) {
|
|
69
|
-
const positionalArgs = argv["_"] as string[];
|
|
70
|
-
let command: Command;
|
|
71
|
-
if (positionalArgs.length > 0) {
|
|
72
|
-
command = positionalArgs[0] as Command;
|
|
73
|
-
} else {
|
|
74
|
-
command = DEFAULT_COMMAND;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let config = new Config();
|
|
78
|
-
if (command !== "init") {
|
|
79
|
-
validateInIsaacScriptProject(verbose);
|
|
80
|
-
config = await configFile.get(argv);
|
|
81
|
-
|
|
82
|
-
ensureDepsAreInstalled(verbose);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
switch (command) {
|
|
86
|
-
case "monitor": {
|
|
87
|
-
monitor(argv, config);
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
case "init": {
|
|
92
|
-
await init(argv);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
case "copy": {
|
|
97
|
-
copy(argv, config);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
case "publish": {
|
|
102
|
-
publish(argv, config);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
default: {
|
|
107
|
-
ensureAllCases(command);
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (command !== "monitor") {
|
|
113
|
-
process.exit(0);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function ensureDepsAreInstalled(verbose: boolean) {
|
|
118
|
-
if (file.exists(YARN_LOCK_PATH, verbose)) {
|
|
119
|
-
console.log(
|
|
120
|
-
'Running "yarn" to ensure that the project\'s dependencies are installed correctly.',
|
|
121
|
-
);
|
|
122
|
-
execShell("yarn");
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// https://stackoverflow.com/questions/57016579/checking-if-package-json-dependencies-match-the-installed-dependencies
|
|
127
|
-
console.log(
|
|
128
|
-
'Running "npm install" to ensure that the project\'s dependencies are installed correctly.',
|
|
129
|
-
);
|
|
130
|
-
execShell("npm", ["install"], verbose);
|
|
131
|
-
}
|
package/src/parseArgs.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import yargs from "yargs";
|
|
2
|
-
import { PROJECT_NAME } from "./constants";
|
|
3
|
-
|
|
4
|
-
export function parseArgs(): Record<string, unknown> {
|
|
5
|
-
const yargsObject = yargs(process.argv.slice(2))
|
|
6
|
-
.strict()
|
|
7
|
-
.usage("usage: isaacscript <command> [options]")
|
|
8
|
-
.scriptName("isaacscript")
|
|
9
|
-
|
|
10
|
-
.command("monitor", "Monitor a project for changes. (default)", (builder) =>
|
|
11
|
-
builder
|
|
12
|
-
.option("mods-directory", {
|
|
13
|
-
alias: "m",
|
|
14
|
-
type: "string",
|
|
15
|
-
description: "The directory where Isaac mods live on your system",
|
|
16
|
-
})
|
|
17
|
-
.option("save-slot", {
|
|
18
|
-
alias: "s",
|
|
19
|
-
type: "number",
|
|
20
|
-
choices: [1, 2, 3],
|
|
21
|
-
description: "The save slot in-game that you use",
|
|
22
|
-
})
|
|
23
|
-
.option("verbose", {
|
|
24
|
-
alias: "v",
|
|
25
|
-
type: "boolean",
|
|
26
|
-
description: "Enable verbose output",
|
|
27
|
-
}),
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
.command(
|
|
31
|
-
"init [name]",
|
|
32
|
-
`Initialize a new ${PROJECT_NAME} mod.`,
|
|
33
|
-
(builder) =>
|
|
34
|
-
builder
|
|
35
|
-
.option("yes", {
|
|
36
|
-
alias: "y",
|
|
37
|
-
type: "boolean",
|
|
38
|
-
description:
|
|
39
|
-
'Answer yes to every dialog option, similar to how "npm init --yes" works.',
|
|
40
|
-
})
|
|
41
|
-
.option("use-current-dir", {
|
|
42
|
-
alias: "u",
|
|
43
|
-
type: "boolean",
|
|
44
|
-
description:
|
|
45
|
-
"Use the current directory as the root for the project",
|
|
46
|
-
})
|
|
47
|
-
.option("mods-directory", {
|
|
48
|
-
alias: "m",
|
|
49
|
-
type: "string",
|
|
50
|
-
description: "The directory where Isaac mods live on your system",
|
|
51
|
-
})
|
|
52
|
-
.option("save-slot", {
|
|
53
|
-
alias: "s",
|
|
54
|
-
type: "number",
|
|
55
|
-
choices: [1, 2, 3],
|
|
56
|
-
description: "The in-game save slot that you use",
|
|
57
|
-
})
|
|
58
|
-
.option("vscode", {
|
|
59
|
-
alias: "c",
|
|
60
|
-
type: "boolean",
|
|
61
|
-
description: "Open the project in VSCode after initialization",
|
|
62
|
-
})
|
|
63
|
-
.option("skip-npm-install", {
|
|
64
|
-
alias: "i",
|
|
65
|
-
type: "boolean",
|
|
66
|
-
description:
|
|
67
|
-
'Don\'t automatically run "npm install" after initializing the project',
|
|
68
|
-
})
|
|
69
|
-
.option("force-name", {
|
|
70
|
-
alias: "f",
|
|
71
|
-
type: "boolean",
|
|
72
|
-
description: "Allow project names that are normally illegal",
|
|
73
|
-
})
|
|
74
|
-
.option("verbose", {
|
|
75
|
-
alias: "v",
|
|
76
|
-
type: "boolean",
|
|
77
|
-
description: "Enable verbose output",
|
|
78
|
-
}),
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
.command("copy", "Only compile & copy the mod.", (builder) =>
|
|
82
|
-
builder.option("verbose", {
|
|
83
|
-
alias: "v",
|
|
84
|
-
type: "boolean",
|
|
85
|
-
description: "Enable verbose output",
|
|
86
|
-
}),
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
.command(
|
|
90
|
-
"publish",
|
|
91
|
-
"Bump the version & automatically publish the new files using the steamcmd tool.",
|
|
92
|
-
(builder) =>
|
|
93
|
-
builder
|
|
94
|
-
.option("skip", {
|
|
95
|
-
alias: "s",
|
|
96
|
-
type: "boolean",
|
|
97
|
-
description: "skip incrementing the version number",
|
|
98
|
-
})
|
|
99
|
-
.option("set-version", {
|
|
100
|
-
alias: "t",
|
|
101
|
-
type: "string",
|
|
102
|
-
description:
|
|
103
|
-
"specify the version number instead of incrementing it",
|
|
104
|
-
})
|
|
105
|
-
.option("dry-run", {
|
|
106
|
-
alias: "d",
|
|
107
|
-
type: "boolean",
|
|
108
|
-
description: "skip invoking steamcmd",
|
|
109
|
-
})
|
|
110
|
-
.option("only-upload", {
|
|
111
|
-
alias: "u",
|
|
112
|
-
type: "boolean",
|
|
113
|
-
description:
|
|
114
|
-
"only upload the mod to the Steam Workshop (without doing anything else)",
|
|
115
|
-
})
|
|
116
|
-
.option("verbose", {
|
|
117
|
-
alias: "v",
|
|
118
|
-
type: "boolean",
|
|
119
|
-
description: "Enable verbose output",
|
|
120
|
-
}),
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
.alias("h", "help") // By default, only "--help" is enabled
|
|
124
|
-
.alias("v", "version"); // By default, only "--version" is enabled
|
|
125
|
-
|
|
126
|
-
return yargsObject.argv as Record<string, unknown>;
|
|
127
|
-
}
|
package/src/prompt.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// Both the Inquirer.js library and the Prompts library have a bug where text is duplicated in a Git
|
|
2
|
-
// Bash terminal. Thus, we revert to using the simpler Prompt library.
|
|
3
|
-
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import prompt from "prompt";
|
|
6
|
-
import { error, parseIntSafe } from "./utils";
|
|
7
|
-
|
|
8
|
-
const VALID_YES_RESPONSES = new Set(["yes", "ye", "y"]);
|
|
9
|
-
const VALID_NO_RESPONSES = new Set(["no", "n"]);
|
|
10
|
-
|
|
11
|
-
export function promptInit(): void {
|
|
12
|
-
// Override some of the prompt library's default values:
|
|
13
|
-
// https://github.com/flatiron/prompt#customizing-your-prompt
|
|
14
|
-
prompt.message = chalk.green("?");
|
|
15
|
-
prompt.delimiter = " ";
|
|
16
|
-
prompt.colors = false;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export async function getInputYesNo(
|
|
20
|
-
msg: string,
|
|
21
|
-
defaultValue = true,
|
|
22
|
-
): Promise<boolean> {
|
|
23
|
-
prompt.start();
|
|
24
|
-
|
|
25
|
-
// Capitalize the letter that represents the default option.
|
|
26
|
-
const y = defaultValue ? "Y" : "y";
|
|
27
|
-
const n = defaultValue ? "n" : "N";
|
|
28
|
-
|
|
29
|
-
const questionSuffix = `(${y}\\${n})`;
|
|
30
|
-
const description = `${chalk.bold(msg)} ${chalk.gray(questionSuffix)}`;
|
|
31
|
-
|
|
32
|
-
const { response } = await prompt.get({
|
|
33
|
-
properties: {
|
|
34
|
-
response: {
|
|
35
|
-
type: "string",
|
|
36
|
-
description,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (typeof response !== "string") {
|
|
42
|
-
console.log(typeof response);
|
|
43
|
-
error("Failed to get a proper response from the prompt library.");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const cleanedResponse = response.toLowerCase().trim();
|
|
47
|
-
|
|
48
|
-
// Default to true.
|
|
49
|
-
if (cleanedResponse === "") {
|
|
50
|
-
return defaultValue;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (VALID_YES_RESPONSES.has(cleanedResponse)) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (VALID_NO_RESPONSES.has(cleanedResponse)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return error('Invalid response; must answer "yes" or "no".');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Returns trimmed input. */
|
|
65
|
-
export async function getInputString(
|
|
66
|
-
msg: string,
|
|
67
|
-
defaultValue?: string,
|
|
68
|
-
): Promise<string> {
|
|
69
|
-
prompt.start();
|
|
70
|
-
|
|
71
|
-
let description = `${chalk.bold(msg)}`;
|
|
72
|
-
if (defaultValue !== undefined) {
|
|
73
|
-
description += ` ${chalk.gray(`(${defaultValue})`)}`;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const { response } = await prompt.get({
|
|
77
|
-
properties: {
|
|
78
|
-
response: {
|
|
79
|
-
type: "string",
|
|
80
|
-
description,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
if (typeof response !== "string") {
|
|
86
|
-
error("Failed to get a proper response from the prompt library.");
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (response === "" && defaultValue !== undefined) {
|
|
90
|
-
return defaultValue;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return response.trim();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export async function getInputInt(
|
|
97
|
-
msg: string,
|
|
98
|
-
defaultValue = 1,
|
|
99
|
-
): Promise<number> {
|
|
100
|
-
const defaultValueString = defaultValue.toString();
|
|
101
|
-
const string = await getInputString(msg, defaultValueString);
|
|
102
|
-
const int = parseIntSafe(string);
|
|
103
|
-
|
|
104
|
-
if (Number.isNaN(int)) {
|
|
105
|
-
error("Error: You must enter an integer.");
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return int;
|
|
109
|
-
}
|
package/src/types/Command.ts
DELETED
package/src/types/Config.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export class Config {
|
|
2
|
-
/** The "mods" directory that lives next to the "isaac-ng.exe" program. */
|
|
3
|
-
modsDirectory =
|
|
4
|
-
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\mods";
|
|
5
|
-
|
|
6
|
-
/** The save slot that you test your mod on. */
|
|
7
|
-
saveSlot = 1;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* By default, the target mod directory name will be the same as the project directory name. This
|
|
11
|
-
* setting allows you to customize it.
|
|
12
|
-
*/
|
|
13
|
-
customTargetModDirectoryName?: string;
|
|
14
|
-
|
|
15
|
-
/** The path to "steamcmd.exe". This is optional and only needed for automating publishing. */
|
|
16
|
-
steamCmdPath?: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* When your code is recompiled, IsaacScript watcher can restart the game to ensure that any
|
|
20
|
-
* run-related variables are properly reset. This is set to true by default.
|
|
21
|
-
*/
|
|
22
|
-
enableIsaacScriptWatcherAutoRestart?: boolean;
|
|
23
|
-
}
|