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
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import {
|
|
4
|
-
CONFIG_FILE_NAME,
|
|
5
|
-
CONSTANTS_TS_PATH,
|
|
6
|
-
METADATA_XML_PATH,
|
|
7
|
-
MOD_SOURCE_PATH,
|
|
8
|
-
MOD_UPLOADER_PATH,
|
|
9
|
-
PACKAGE_JSON_PATH,
|
|
10
|
-
PROJECT_NAME,
|
|
11
|
-
PUBLISH_POST_COPY_PY_PATH,
|
|
12
|
-
PUBLISH_PRE_COPY_PY_PATH,
|
|
13
|
-
VERSION_TXT_PATH,
|
|
14
|
-
} from "../../constants";
|
|
15
|
-
import { execExe, execPowershell, execShell } from "../../exec";
|
|
16
|
-
import * as file from "../../file";
|
|
17
|
-
import { Config } from "../../types/Config";
|
|
18
|
-
import { error, getModTargetDirectoryName, parseIntSafe } from "../../utils";
|
|
19
|
-
import { compileAndCopy } from "../copy/copy";
|
|
20
|
-
import { gitCommitIfChanges, isGitDirty } from "../init/git";
|
|
21
|
-
|
|
22
|
-
const UPDATE_SCRIPT_NAME = "update.sh";
|
|
23
|
-
|
|
24
|
-
export function publish(argv: Record<string, unknown>, config: Config): void {
|
|
25
|
-
const skipVersionIncrement = argv["skip"] === true;
|
|
26
|
-
const setVersion = argv["setVersion"] as string | undefined;
|
|
27
|
-
const dryRun = argv["dryRun"] === true;
|
|
28
|
-
const onlyUpload = argv["onlyUpload"] === true;
|
|
29
|
-
const verbose = argv["verbose"] === true;
|
|
30
|
-
|
|
31
|
-
const modTargetDirectoryName = getModTargetDirectoryName(config);
|
|
32
|
-
const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
|
|
33
|
-
|
|
34
|
-
validateVersion(setVersion);
|
|
35
|
-
validateGitNotDirty(verbose);
|
|
36
|
-
validateIsaacScriptOtherCopiesNotRunning(verbose);
|
|
37
|
-
|
|
38
|
-
if (onlyUpload) {
|
|
39
|
-
uploadMod(modTargetPath, config.steamCmdPath, verbose);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
startPublish(
|
|
44
|
-
MOD_SOURCE_PATH,
|
|
45
|
-
modTargetPath,
|
|
46
|
-
skipVersionIncrement,
|
|
47
|
-
setVersion,
|
|
48
|
-
config.steamCmdPath,
|
|
49
|
-
dryRun,
|
|
50
|
-
verbose,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function validateVersion(setVersion: string | undefined) {
|
|
55
|
-
if (setVersion !== undefined && /^\d+\.\d+\.\d+$/.exec(setVersion) === null) {
|
|
56
|
-
error(
|
|
57
|
-
chalk.red(
|
|
58
|
-
`The version of "${setVersion}" does not match the semantic versioning format.`,
|
|
59
|
-
),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function validateGitNotDirty(verbose: boolean) {
|
|
65
|
-
if (isGitDirty(verbose)) {
|
|
66
|
-
error(
|
|
67
|
-
chalk.red(
|
|
68
|
-
"Before publishing, you must push your current changes to git. (Version commits should be not contain any code changes.)",
|
|
69
|
-
),
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function validateIsaacScriptOtherCopiesNotRunning(verbose: boolean) {
|
|
75
|
-
if (process.platform !== "win32") {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// From: https://securityboulevard.com/2020/01/get-process-list-with-command-line-arguments/
|
|
80
|
-
const stdout = execPowershell(
|
|
81
|
-
"Get-WmiObject Win32_Process -Filter \"name = 'node.exe'\" | Select-Object -ExpandProperty CommandLine",
|
|
82
|
-
verbose,
|
|
83
|
-
);
|
|
84
|
-
const lines = stdout.split("\r\n");
|
|
85
|
-
const otherCopiesOfRunningIsaacScript = lines.filter(
|
|
86
|
-
(line) =>
|
|
87
|
-
line.includes("node.exe") &&
|
|
88
|
-
line.includes("isaacscript") &&
|
|
89
|
-
!line.includes("isaacscript publish"),
|
|
90
|
-
);
|
|
91
|
-
if (otherCopiesOfRunningIsaacScript.length > 0) {
|
|
92
|
-
error(
|
|
93
|
-
chalk.red(
|
|
94
|
-
`Other copies of ${PROJECT_NAME} appear to be running. You must close those copies before publishing.`,
|
|
95
|
-
),
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function startPublish(
|
|
101
|
-
modSourcePath: string,
|
|
102
|
-
modTargetPath: string,
|
|
103
|
-
skipVersionIncrement: boolean,
|
|
104
|
-
setVersion: string | undefined,
|
|
105
|
-
steamCmdPath: string | undefined,
|
|
106
|
-
dryRun: boolean,
|
|
107
|
-
verbose: boolean,
|
|
108
|
-
) {
|
|
109
|
-
updateDeps(verbose);
|
|
110
|
-
|
|
111
|
-
let version =
|
|
112
|
-
setVersion === undefined ? getVersionFromPackageJSON(verbose) : setVersion;
|
|
113
|
-
if (!skipVersionIncrement && setVersion === undefined) {
|
|
114
|
-
version = bumpVersionInPackageJSON(version, verbose);
|
|
115
|
-
} else if (setVersion !== undefined) {
|
|
116
|
-
writeVersionInPackageJSON(version, verbose);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
writeVersionToConstantsTS(version, verbose);
|
|
120
|
-
writeVersionToMetadataXML(version, verbose);
|
|
121
|
-
writeVersionToVersionTXT(version, verbose);
|
|
122
|
-
runReleaseScriptPreCopy(verbose);
|
|
123
|
-
compileAndCopy(modSourcePath, modTargetPath, verbose);
|
|
124
|
-
purgeRoomXMLs(modTargetPath, verbose);
|
|
125
|
-
runReleaseScriptPostCopy(verbose);
|
|
126
|
-
|
|
127
|
-
if (!dryRun) {
|
|
128
|
-
gitCommitIfChanges(version, verbose);
|
|
129
|
-
uploadMod(modTargetPath, steamCmdPath, verbose);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const dryRunSuffix = dryRun ? " (dry run)" : "";
|
|
133
|
-
console.log(`\nPublished version ${version} successfully${dryRunSuffix}.`);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function updateDeps(verbose: boolean) {
|
|
137
|
-
if (!file.exists(UPDATE_SCRIPT_NAME, verbose)) {
|
|
138
|
-
error(
|
|
139
|
-
`The "${UPDATE_SCRIPT_NAME}" script does not exist in the current working directory.`,
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
execShell("bash", [UPDATE_SCRIPT_NAME], verbose);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function getVersionFromPackageJSON(verbose: boolean) {
|
|
147
|
-
if (!file.exists(PACKAGE_JSON_PATH, verbose)) {
|
|
148
|
-
error(
|
|
149
|
-
chalk.red(
|
|
150
|
-
`A "${PACKAGE_JSON_PATH}" was not found in the current directory.`,
|
|
151
|
-
),
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const packageJSONRaw = file.read(PACKAGE_JSON_PATH, verbose);
|
|
156
|
-
let packageJSON: Record<string, unknown>;
|
|
157
|
-
try {
|
|
158
|
-
packageJSON = JSON.parse(packageJSONRaw) as Record<string, unknown>;
|
|
159
|
-
} catch (err) {
|
|
160
|
-
error(`Failed to parse "${chalk.green(PACKAGE_JSON_PATH)}":`, err);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (!Object.prototype.hasOwnProperty.call(packageJSON, "version")) {
|
|
164
|
-
error(
|
|
165
|
-
`The "${chalk.green(
|
|
166
|
-
PACKAGE_JSON_PATH,
|
|
167
|
-
)}" file does not have a "version" field.`,
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (typeof packageJSON["version"] !== "string") {
|
|
172
|
-
error(
|
|
173
|
-
`The "${chalk.green(
|
|
174
|
-
PACKAGE_JSON_PATH,
|
|
175
|
-
)}" file has a "version" field that is not a string.`,
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return packageJSON["version"];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function bumpVersionInPackageJSON(version: string, verbose: boolean): string {
|
|
183
|
-
// Get the patch version (i.e. the third number)
|
|
184
|
-
const matches = /(\d+\.\d+\.)(\d+)/.exec(version);
|
|
185
|
-
if (matches === null) {
|
|
186
|
-
error(`Failed to parse the version of: ${version}`);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const versionPrefix = matches[1];
|
|
190
|
-
if (versionPrefix === undefined) {
|
|
191
|
-
error(`Failed to parse the first part of the version: ${version}`);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const patchVersionString = matches[2];
|
|
195
|
-
if (patchVersionString === undefined) {
|
|
196
|
-
error(`Failed to parse the second part of the version: ${version}`);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const patchVersion = parseIntSafe(patchVersionString);
|
|
200
|
-
if (Number.isNaN(patchVersion)) {
|
|
201
|
-
error(`Failed to convert "${patchVersionString}" to a number.`);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const incrementedPatchVersion = patchVersion + 1;
|
|
205
|
-
const incrementedVersion = `${versionPrefix}${incrementedPatchVersion}`;
|
|
206
|
-
|
|
207
|
-
const packageJSON = file.read(PACKAGE_JSON_PATH, verbose);
|
|
208
|
-
const newPackageJSON = packageJSON.replace(
|
|
209
|
-
/"version": ".+",/,
|
|
210
|
-
`"version": "${incrementedVersion}",`,
|
|
211
|
-
);
|
|
212
|
-
file.write(PACKAGE_JSON_PATH, newPackageJSON, verbose);
|
|
213
|
-
|
|
214
|
-
console.log(
|
|
215
|
-
`The version of ${incrementedVersion} was written to: ${PACKAGE_JSON_PATH}`,
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
return incrementedVersion;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function writeVersionInPackageJSON(version: string, verbose: boolean) {
|
|
222
|
-
const packageJSON = file.read(PACKAGE_JSON_PATH, verbose);
|
|
223
|
-
const newPackageJSON = packageJSON.replace(
|
|
224
|
-
/"version": ".+",/,
|
|
225
|
-
`"version": "${version}",`,
|
|
226
|
-
);
|
|
227
|
-
file.write(PACKAGE_JSON_PATH, newPackageJSON, verbose);
|
|
228
|
-
|
|
229
|
-
console.log(`The version of ${version} was written to: ${PACKAGE_JSON_PATH}`);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function writeVersionToConstantsTS(version: string, verbose: boolean) {
|
|
233
|
-
if (!file.exists(CONSTANTS_TS_PATH, verbose)) {
|
|
234
|
-
console.log(
|
|
235
|
-
'Skipping writing the version to "constants.ts" since it was not found.',
|
|
236
|
-
);
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const constantsTS = file.read(CONSTANTS_TS_PATH, verbose);
|
|
241
|
-
const newConstantsTS = constantsTS.replace(
|
|
242
|
-
/const VERSION = ".+"/,
|
|
243
|
-
`const VERSION = "${version}"`,
|
|
244
|
-
);
|
|
245
|
-
file.write(CONSTANTS_TS_PATH, newConstantsTS, verbose);
|
|
246
|
-
|
|
247
|
-
console.log(`The version of ${version} was written to: ${CONSTANTS_TS_PATH}`);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function writeVersionToMetadataXML(version: string, verbose: boolean) {
|
|
251
|
-
const metadataXML = file.read(METADATA_XML_PATH, verbose);
|
|
252
|
-
const newMetadataXML = metadataXML.replace(
|
|
253
|
-
/<version>.+<\/version>/,
|
|
254
|
-
`<version>${version}</version>`,
|
|
255
|
-
);
|
|
256
|
-
file.write(METADATA_XML_PATH, newMetadataXML, verbose);
|
|
257
|
-
|
|
258
|
-
console.log(`The version of ${version} was written to: ${METADATA_XML_PATH}`);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function writeVersionToVersionTXT(version: string, verbose: boolean) {
|
|
262
|
-
file.write(VERSION_TXT_PATH, version, verbose);
|
|
263
|
-
|
|
264
|
-
console.log(`The version of ${version} was written to: ${VERSION_TXT_PATH}`);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function runReleaseScriptPreCopy(verbose: boolean) {
|
|
268
|
-
if (!file.exists(PUBLISH_PRE_COPY_PY_PATH, verbose)) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
console.log(`Running the "${PUBLISH_PRE_COPY_PY_PATH}" script.`);
|
|
273
|
-
let [, stdout] = execShell("python", [PUBLISH_PRE_COPY_PY_PATH], verbose);
|
|
274
|
-
stdout = stdout.trim();
|
|
275
|
-
if (stdout.length > 0) {
|
|
276
|
-
console.log(stdout);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function runReleaseScriptPostCopy(verbose: boolean) {
|
|
281
|
-
if (!file.exists(PUBLISH_POST_COPY_PY_PATH, verbose)) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
console.log(`Running the "${PUBLISH_POST_COPY_PY_PATH}" script.`);
|
|
286
|
-
let [, stdout] = execShell("python", [PUBLISH_POST_COPY_PY_PATH], verbose);
|
|
287
|
-
stdout = stdout.trim();
|
|
288
|
-
if (stdout.length > 0) {
|
|
289
|
-
console.log(stdout);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function purgeRoomXMLs(modTargetPath: string, verbose: boolean) {
|
|
294
|
-
const roomsPath = path.join(modTargetPath, "resources", "rooms");
|
|
295
|
-
if (!file.exists(roomsPath, verbose) || !file.isDir(roomsPath, verbose)) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const roomFileList = file.getDirList(roomsPath, verbose);
|
|
300
|
-
roomFileList.forEach((fileName: string) => {
|
|
301
|
-
if (path.extname(fileName) === ".xml") {
|
|
302
|
-
const roomFilePath = path.join(roomsPath, fileName);
|
|
303
|
-
file.deleteFileOrDirectory(roomFilePath, verbose);
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function uploadMod(
|
|
309
|
-
modTargetPath: string,
|
|
310
|
-
steamCmdPath: string | undefined,
|
|
311
|
-
verbose: boolean,
|
|
312
|
-
) {
|
|
313
|
-
if (steamCmdPath === undefined) {
|
|
314
|
-
console.log(
|
|
315
|
-
`The "steamCmdPath" property was not found in the "${chalk.green(
|
|
316
|
-
CONFIG_FILE_NAME,
|
|
317
|
-
)}" file; assuming that we want to use the ModUploader tool.`,
|
|
318
|
-
);
|
|
319
|
-
execExe(MOD_UPLOADER_PATH, verbose, modTargetPath);
|
|
320
|
-
} else {
|
|
321
|
-
runSteamCmd(modTargetPath, steamCmdPath, verbose);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
function runSteamCmd(
|
|
326
|
-
modTargetPath: string,
|
|
327
|
-
steamCmdPath: string,
|
|
328
|
-
verbose: boolean,
|
|
329
|
-
) {
|
|
330
|
-
if (!file.exists(steamCmdPath, verbose)) {
|
|
331
|
-
error(
|
|
332
|
-
chalk.red(
|
|
333
|
-
`The path provided for "steamCmdPath" is "${steamCmdPath}", but that does not exist.`,
|
|
334
|
-
),
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const metadataVDFPath = path.join(modTargetPath, "metadata.vdf");
|
|
339
|
-
if (!file.exists(metadataVDFPath, verbose)) {
|
|
340
|
-
console.error(
|
|
341
|
-
chalk.red(
|
|
342
|
-
`A "metadata.vdf" file was not found in your mod directory. You must create this file in order for "steamcmd.exe" to work. Please see the ${PROJECT_NAME} docs:`,
|
|
343
|
-
),
|
|
344
|
-
);
|
|
345
|
-
error(getIsaacScriptDocs());
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const usernameVar = "STEAM_USERNAME";
|
|
349
|
-
const username = process.env[usernameVar];
|
|
350
|
-
if (username === undefined || username === "") {
|
|
351
|
-
console.error(
|
|
352
|
-
chalk.red(
|
|
353
|
-
`Failed to read the "${usernameVar}" environment variable from the ".env" file. Please see the ${PROJECT_NAME} docs:`,
|
|
354
|
-
),
|
|
355
|
-
);
|
|
356
|
-
error(getIsaacScriptDocs());
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
const passwordVar = "STEAM_PASSWORD";
|
|
360
|
-
const password = process.env[passwordVar];
|
|
361
|
-
if (password === undefined || password === "") {
|
|
362
|
-
console.error(
|
|
363
|
-
chalk.red(
|
|
364
|
-
`Failed to read the "${passwordVar}" environment variable from the ".env" file. Please see the ${PROJECT_NAME} docs:`,
|
|
365
|
-
),
|
|
366
|
-
);
|
|
367
|
-
error(getIsaacScriptDocs());
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
console.log("Uploading the mod to the Steam Workshop...");
|
|
371
|
-
|
|
372
|
-
execShell(
|
|
373
|
-
steamCmdPath,
|
|
374
|
-
[
|
|
375
|
-
"+login",
|
|
376
|
-
username,
|
|
377
|
-
password,
|
|
378
|
-
"+workshop_build_item",
|
|
379
|
-
metadataVDFPath,
|
|
380
|
-
"+quit",
|
|
381
|
-
],
|
|
382
|
-
verbose,
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
console.log("Mod uploaded successfully.");
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function getIsaacScriptDocs() {
|
|
389
|
-
return chalk.red(
|
|
390
|
-
"https://isaacscript.github.io/docs/publishing-to-the-workshop/#metadatavdf",
|
|
391
|
-
);
|
|
392
|
-
}
|
package/src/configFile.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import * as JSONC from "jsonc-parser";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { getModsDir } from "./commands/init/getModsDir";
|
|
5
|
-
import { promptSaveSlot } from "./commands/init/promptSaveSlot";
|
|
6
|
-
import { CONFIG_FILE_NAME, CONFIG_FILE_PATH, CWD } from "./constants";
|
|
7
|
-
import * as file from "./file";
|
|
8
|
-
import { Config } from "./types/Config";
|
|
9
|
-
import { error } from "./utils";
|
|
10
|
-
|
|
11
|
-
export async function get(argv: Record<string, unknown>): Promise<Config> {
|
|
12
|
-
const verbose = argv["verbose"] === true;
|
|
13
|
-
const yes = argv["yes"] === true;
|
|
14
|
-
|
|
15
|
-
const existingConfig = readExistingConfig(verbose);
|
|
16
|
-
if (existingConfig !== undefined) {
|
|
17
|
-
return existingConfig;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// No config file exists, so prompt the user for some information and create one
|
|
21
|
-
const modsDirectory = await getModsDir(argv, verbose);
|
|
22
|
-
const saveSlot = await promptSaveSlot(argv, yes);
|
|
23
|
-
const config = createObject(modsDirectory, saveSlot);
|
|
24
|
-
createFile(CWD, config, verbose);
|
|
25
|
-
|
|
26
|
-
return config;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function readExistingConfig(verbose: boolean): Config | undefined {
|
|
30
|
-
if (!file.exists(CONFIG_FILE_PATH, verbose)) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const configRaw = file.read(CONFIG_FILE_PATH, verbose);
|
|
35
|
-
let config: Config;
|
|
36
|
-
try {
|
|
37
|
-
config = JSONC.parse(configRaw) as Config;
|
|
38
|
-
} catch (err) {
|
|
39
|
-
error(`Failed to parse the "${chalk.green(CONFIG_FILE_PATH)}" file:`, err);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (config.modsDirectory === undefined) {
|
|
43
|
-
errorMissing(
|
|
44
|
-
"modsDirectory",
|
|
45
|
-
"This should be equal to the directory where Isaac mods live on your system.",
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (config.saveSlot === undefined) {
|
|
50
|
-
errorMissing(
|
|
51
|
-
"saveSlot",
|
|
52
|
-
"This should be equal to the save slot that you test your mods on.",
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return config;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function errorMissing(field: string, description: string) {
|
|
60
|
-
error(
|
|
61
|
-
`The "${CONFIG_FILE_NAME}" file is missing a "${field}" value. ${description} Please add it.`,
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function createObject(modsDirectory: string, saveSlot: number): Config {
|
|
66
|
-
return {
|
|
67
|
-
modsDirectory,
|
|
68
|
-
saveSlot,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function createFile(
|
|
73
|
-
projectPath: string,
|
|
74
|
-
config: Config,
|
|
75
|
-
verbose: boolean,
|
|
76
|
-
): void {
|
|
77
|
-
const configFilePath = path.join(projectPath, CONFIG_FILE_NAME);
|
|
78
|
-
const configContents = JSON.stringify(config, null, 2);
|
|
79
|
-
file.write(configFilePath, configContents, verbose);
|
|
80
|
-
}
|
package/src/constants.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import os from "os";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
const cwd = process.cwd();
|
|
5
|
-
|
|
6
|
-
// https://stackoverflow.com/questions/9080085/node-js-find-home-directory-in-platform-agnostic-way
|
|
7
|
-
const homeDir = os.homedir();
|
|
8
|
-
|
|
9
|
-
// Miscellaneous
|
|
10
|
-
export const CURRENT_DIRECTORY_NAME = path.basename(cwd);
|
|
11
|
-
export const CWD = cwd;
|
|
12
|
-
export const HOME_DIR = homeDir;
|
|
13
|
-
export const FILE_SYNCED_MESSAGE = "File synced:";
|
|
14
|
-
export const MOD_UPLOADER_PATH =
|
|
15
|
-
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\tools\\ModUploader\\ModUploader.exe";
|
|
16
|
-
export const PROJECT_NAME = "IsaacScript";
|
|
17
|
-
|
|
18
|
-
// isaacscript
|
|
19
|
-
const REPO_ROOT = path.join(__dirname, "..", "..");
|
|
20
|
-
|
|
21
|
-
// isaacscript/isaacscript-watcher
|
|
22
|
-
export const DISABLE_IT_FILE = "disable.it";
|
|
23
|
-
export const WATCHER_MOD_NAME = "isaacscript-watcher";
|
|
24
|
-
export const WATCHER_MOD_SOURCE_PATH = path.join(REPO_ROOT, WATCHER_MOD_NAME);
|
|
25
|
-
|
|
26
|
-
// isaacscript/file-templates
|
|
27
|
-
const TEMPLATES_DIR = path.join(REPO_ROOT, "file-templates");
|
|
28
|
-
|
|
29
|
-
// isaacscript/file-templates/static
|
|
30
|
-
export const TEMPLATES_STATIC_DIR = path.join(TEMPLATES_DIR, "static");
|
|
31
|
-
|
|
32
|
-
// isaacscript/file-templates/dynamic
|
|
33
|
-
const TEMPLATES_DYNAMIC_DIR = path.join(TEMPLATES_DIR, "dynamic");
|
|
34
|
-
export const GITIGNORE = "gitignore"; // Not named ".gitignore" to prevent NPM from deleting it
|
|
35
|
-
export const GITIGNORE_TEMPLATE_PATH = path.join(
|
|
36
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
37
|
-
GITIGNORE,
|
|
38
|
-
);
|
|
39
|
-
export const MAIN_TS = "main.ts";
|
|
40
|
-
export const MAIN_TS_TEMPLATE_PATH = path.join(TEMPLATES_DYNAMIC_DIR, MAIN_TS);
|
|
41
|
-
export const METADATA_XML = "metadata.xml";
|
|
42
|
-
export const METADATA_XML_TEMPLATE_PATH = path.join(
|
|
43
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
44
|
-
METADATA_XML,
|
|
45
|
-
);
|
|
46
|
-
export const METADATA_VDF = "metadata.vdf";
|
|
47
|
-
export const METADATA_VDF_TEMPLATE_PATH = path.join(
|
|
48
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
49
|
-
METADATA_VDF,
|
|
50
|
-
);
|
|
51
|
-
export const PACKAGE_JSON = "package.json";
|
|
52
|
-
export const PACKAGE_JSON_TEMPLATE_PATH = path.join(
|
|
53
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
54
|
-
PACKAGE_JSON,
|
|
55
|
-
);
|
|
56
|
-
export const README_MD = "README.md";
|
|
57
|
-
export const README_MD_TEMPLATES_PATH = path.join(
|
|
58
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
59
|
-
README_MD,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// project
|
|
63
|
-
export const CONFIG_FILE_NAME = "isaacscript.json";
|
|
64
|
-
export const CONFIG_FILE_PATH = path.join(CWD, CONFIG_FILE_NAME);
|
|
65
|
-
export const TSCONFIG_PATH = path.join(CWD, "tsconfig.json");
|
|
66
|
-
export const PACKAGE_JSON_PATH = path.join(CWD, "package.json");
|
|
67
|
-
export const CONSTANTS_TS_PATH = path.join(CWD, "src", "constants.ts");
|
|
68
|
-
export const YARN_LOCK_PATH = path.join(CWD, "yarn.lock");
|
|
69
|
-
|
|
70
|
-
// project/mod
|
|
71
|
-
export const MOD_SOURCE_PATH = path.join(CWD, "mod");
|
|
72
|
-
export const MAIN_LUA = "main.lua";
|
|
73
|
-
export const METADATA_XML_PATH = path.join(MOD_SOURCE_PATH, "metadata.xml");
|
|
74
|
-
export const VERSION_TXT_PATH = path.join(MOD_SOURCE_PATH, "version.txt");
|
|
75
|
-
|
|
76
|
-
// project/scripts
|
|
77
|
-
const SCRIPTS_PATH = path.join(CWD, "scripts");
|
|
78
|
-
export const PUBLISH_PRE_COPY_PY_PATH = path.join(
|
|
79
|
-
SCRIPTS_PATH,
|
|
80
|
-
"publish_pre_copy.py",
|
|
81
|
-
);
|
|
82
|
-
export const PUBLISH_POST_COPY_PY_PATH = path.join(
|
|
83
|
-
SCRIPTS_PATH,
|
|
84
|
-
"publish_post_copy.py",
|
|
85
|
-
);
|
package/src/exec.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { execSync, spawnSync, SpawnSyncReturns } from "child_process";
|
|
3
|
-
import { CWD } from "./constants";
|
|
4
|
-
import { error } from "./utils";
|
|
5
|
-
|
|
6
|
-
export function execExe(path: string, verbose: boolean, cwd = CWD): string {
|
|
7
|
-
if (verbose) {
|
|
8
|
-
console.log(`Executing binary: ${path}`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let stdout: string;
|
|
12
|
-
try {
|
|
13
|
-
const buffer = execSync(`"${path}"`, {
|
|
14
|
-
cwd,
|
|
15
|
-
});
|
|
16
|
-
stdout = buffer.toString().trim();
|
|
17
|
-
} catch (err) {
|
|
18
|
-
error(`Failed to run "${chalk.green(path)}":`, err);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (verbose) {
|
|
22
|
-
console.log(`Executed binary: ${path}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return stdout;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function execPowershell(
|
|
29
|
-
command: string,
|
|
30
|
-
verbose = false,
|
|
31
|
-
cwd = CWD,
|
|
32
|
-
): string {
|
|
33
|
-
if (verbose) {
|
|
34
|
-
console.log(`Executing PowerShell command: ${command}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let stdout: string;
|
|
38
|
-
try {
|
|
39
|
-
const buffer = execSync(command, {
|
|
40
|
-
shell: "powershell.exe",
|
|
41
|
-
cwd,
|
|
42
|
-
});
|
|
43
|
-
stdout = buffer.toString().trim();
|
|
44
|
-
} catch (err) {
|
|
45
|
-
error(`Failed to run PowerShell command "${chalk.green(command)}":`, err);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (verbose) {
|
|
49
|
-
console.log(`Executed PowerShell command: ${command}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return stdout;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Returns a tuple of exit status and stdout. The stdout is trimmed for convenience. */
|
|
56
|
-
export function execShell(
|
|
57
|
-
command: string,
|
|
58
|
-
args: string[] = [],
|
|
59
|
-
verbose = false,
|
|
60
|
-
allowFailure = false,
|
|
61
|
-
cwd = CWD,
|
|
62
|
-
): [exitStatus: number, stdout: string] {
|
|
63
|
-
// On Windows, "spawnSync()" will not account for spaces in arguments. Thus, wrap everything in a
|
|
64
|
-
// double quote. This will cause arguments that naturally have double quotes to fail.
|
|
65
|
-
if (command.includes('"')) {
|
|
66
|
-
error(
|
|
67
|
-
"execShell cannot execute commands with double quotes in the command.",
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const argsHasDoubleQuotes = args.some((arg) => arg.includes('"'));
|
|
72
|
-
if (argsHasDoubleQuotes) {
|
|
73
|
-
error(
|
|
74
|
-
"execShell cannot execute commands with double quotes in the arguments.",
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const quotedArgs = args.map((arg) => `"${arg}"`);
|
|
79
|
-
const commandDescription = `${command} ${quotedArgs.join(" ")}`.trim();
|
|
80
|
-
|
|
81
|
-
if (verbose) {
|
|
82
|
-
console.log(`Executing command: ${commandDescription}`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
let spawnSyncReturns: SpawnSyncReturns<Buffer>;
|
|
86
|
-
try {
|
|
87
|
-
spawnSyncReturns = spawnSync(command, args, {
|
|
88
|
-
shell: true,
|
|
89
|
-
cwd,
|
|
90
|
-
});
|
|
91
|
-
} catch (err) {
|
|
92
|
-
error(
|
|
93
|
-
`Failed to run the "${chalk.green(commandDescription)}" command:`,
|
|
94
|
-
err,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (verbose) {
|
|
99
|
-
console.log(`Executed command: ${commandDescription}`);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const exitStatus = spawnSyncReturns.status;
|
|
103
|
-
if (exitStatus === null) {
|
|
104
|
-
error(`Failed to get the return status of command: ${commandDescription}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const stdout = spawnSyncReturns.output.join("\n").trim();
|
|
108
|
-
|
|
109
|
-
if (exitStatus !== 0) {
|
|
110
|
-
if (allowFailure) {
|
|
111
|
-
return [exitStatus, stdout];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
console.error(
|
|
115
|
-
`Failed to run the "${chalk.green(
|
|
116
|
-
commandDescription,
|
|
117
|
-
)}" command with an exit code of ${exitStatus}.`,
|
|
118
|
-
);
|
|
119
|
-
console.error("The output was as follows:");
|
|
120
|
-
console.error(stdout);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return [exitStatus, stdout];
|
|
125
|
-
}
|