isaacscript 2.0.14-dev.8 → 2.0.15-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +4 -6
- package/file-templates/dynamic/gitignore +3 -0
- package/file-templates/static/{.eslintrc.js → .eslintrc.js.template} +0 -0
- package/file-templates/static/.github/workflows/ci.yml +4 -3
- package/file-templates/static/.prettierignore +1 -1
- package/file-templates/static/check-orphaned-words.sh +3 -3
- package/file-templates/static/{.cspell.json.template → cspell.json.template} +1 -1
- package/file-templates/static-alt/.prettierignore-base +1 -1
- package/package.json +7 -2
- package/src/checkForWindowsTerminalBugs.js +75 -79
- package/src/checkForWindowsTerminalBugs.js.map +1 -1
- package/src/commands/copy/copy.js +32 -32
- package/src/commands/init/checkIfProjectPathExists.js +27 -29
- package/src/commands/init/checkIfProjectPathExists.js.map +1 -1
- package/src/commands/init/checkModSubdirectory.js +15 -15
- package/src/commands/init/checkModTargetDirectory.js +30 -32
- package/src/commands/init/checkModTargetDirectory.js.map +1 -1
- package/src/commands/init/createMod.js +142 -137
- package/src/commands/init/createMod.js.map +1 -1
- package/src/commands/init/getModsDir.js +55 -57
- package/src/commands/init/getModsDir.js.map +1 -1
- package/src/commands/init/getProjectPath.js +88 -92
- package/src/commands/init/getProjectPath.js.map +1 -1
- package/src/commands/init/git.js +150 -152
- package/src/commands/init/git.js.map +1 -1
- package/src/commands/init/init.js +65 -69
- package/src/commands/init/init.js.map +1 -1
- package/src/commands/init/installVSCodeExtensions.js +32 -32
- package/src/commands/init/promptSaveSlot.js +21 -24
- package/src/commands/init/promptSaveSlot.js.map +1 -1
- package/src/commands/init/promptVSCode.js +24 -26
- package/src/commands/init/promptVSCode.js.map +1 -1
- package/src/commands/monitor/constants.js +4 -4
- package/src/commands/monitor/copyWatcherMod.js +38 -38
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +49 -49
- package/src/commands/monitor/monitor.js +146 -146
- package/src/commands/monitor/notifyGame.js +57 -57
- package/src/commands/monitor/saveDatWriter/saveDatWriter.js +116 -116
- package/src/commands/monitor/saveDatWriter/types.js +2 -2
- package/src/commands/monitor/spawnSaveDatWriter.js +34 -34
- package/src/commands/monitor/touchWatcherSaveDatFiles.js +20 -20
- package/src/commands/publish/publish.js +220 -220
- package/src/configFile.js +63 -65
- package/src/configFile.js.map +1 -1
- package/src/constants.js +59 -59
- package/src/exec.js +95 -95
- package/src/file.js +193 -193
- package/src/main.js +117 -121
- package/src/main.js.map +1 -1
- package/src/parseArgs.js +106 -106
- package/src/prompt.js +86 -92
- package/src/prompt.js.map +1 -1
- package/src/types/Command.js +4 -4
- package/src/types/Config.js +12 -12
- package/src/types/GitHubCLIHostsYAML.js +2 -2
- package/src/utils.js +81 -81
- package/src/validateInIsaacScriptProject.js +26 -26
- package/src/validateNodeVersion.js +24 -24
- package/src/validateOS.js +16 -16
- package/file-templates/static/.gitattributes +0 -9
- package/file-templates/static/nuke.sh +0 -18
- package/file-templates/static/publish.sh +0 -10
- package/src/checkForWindowsTerminalBugs.d.ts +0 -5
- package/src/commands/copy/copy.d.ts +0 -3
- package/src/commands/init/checkIfProjectPathExists.d.ts +0 -1
- package/src/commands/init/checkModSubdirectory.d.ts +0 -1
- package/src/commands/init/checkModTargetDirectory.d.ts +0 -1
- package/src/commands/init/createMod.d.ts +0 -1
- package/src/commands/init/getModsDir.d.ts +0 -1
- package/src/commands/init/getProjectPath.d.ts +0 -1
- package/src/commands/init/git.d.ts +0 -4
- package/src/commands/init/init.d.ts +0 -1
- package/src/commands/init/installVSCodeExtensions.d.ts +0 -1
- package/src/commands/init/promptSaveSlot.d.ts +0 -1
- package/src/commands/init/promptVSCode.d.ts +0 -1
- package/src/commands/monitor/constants.d.ts +0 -1
- package/src/commands/monitor/copyWatcherMod.d.ts +0 -2
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.d.ts +0 -1
- package/src/commands/monitor/monitor.d.ts +0 -2
- package/src/commands/monitor/notifyGame.d.ts +0 -3
- package/src/commands/monitor/saveDatWriter/saveDatWriter.d.ts +0 -1
- package/src/commands/monitor/saveDatWriter/types.d.ts +0 -5
- package/src/commands/monitor/spawnSaveDatWriter.d.ts +0 -4
- package/src/commands/monitor/touchWatcherSaveDatFiles.d.ts +0 -2
- package/src/commands/publish/publish.d.ts +0 -2
- package/src/configFile.d.ts +0 -4
- package/src/constants.d.ts +0 -34
- package/src/exec.d.ts +0 -4
- package/src/file.d.ts +0 -12
- package/src/main.d.ts +0 -2
- package/src/parseArgs.d.ts +0 -1
- package/src/prompt.d.ts +0 -5
- package/src/types/Command.d.ts +0 -2
- package/src/types/Config.d.ts +0 -18
- package/src/types/GitHubCLIHostsYAML.d.ts +0 -7
- package/src/utils.d.ts +0 -13
- package/src/validateInIsaacScriptProject.d.ts +0 -1
- package/src/validateNodeVersion.d.ts +0 -5
- package/src/validateOS.d.ts +0 -1
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendMsgToSaveDatWriter = exports.spawnSaveDatWriter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const constants_1 = require("../../constants");
|
|
8
|
-
const utils_1 = require("../../utils");
|
|
9
|
-
let saveDatWriter = null;
|
|
10
|
-
function spawnSaveDatWriter(config) {
|
|
11
|
-
const processName = "saveDatWriter";
|
|
12
|
-
const processDescription = "save#.dat writer";
|
|
13
|
-
const processPath = path_1.default.join(__dirname, processName, processName);
|
|
14
|
-
const modsDataPath = path_1.default.join(config.modsDirectory, "..", "data");
|
|
15
|
-
const watcherModDataPath = path_1.default.join(modsDataPath, constants_1.WATCHER_MOD_NAME);
|
|
16
|
-
const saveDatFileName = `save${config.saveSlot}.dat`;
|
|
17
|
-
const saveDatPath = path_1.default.join(watcherModDataPath, saveDatFileName);
|
|
18
|
-
saveDatWriter = (0, child_process_1.fork)(processPath, [saveDatPath], {
|
|
19
|
-
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
20
|
-
});
|
|
21
|
-
saveDatWriter.on("close", (code) => {
|
|
22
|
-
(0, utils_1.error)(`Error: ${processDescription} subprocess closed with code: ${code}`);
|
|
23
|
-
});
|
|
24
|
-
saveDatWriter.on("exit", (code) => {
|
|
25
|
-
(0, utils_1.error)(`Error: ${processDescription} subprocess exited with code: ${code}`);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
exports.spawnSaveDatWriter = spawnSaveDatWriter;
|
|
29
|
-
function sendMsgToSaveDatWriter(msg) {
|
|
30
|
-
if (saveDatWriter !== null) {
|
|
31
|
-
saveDatWriter.send(msg);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.sendMsgToSaveDatWriter = sendMsgToSaveDatWriter;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendMsgToSaveDatWriter = exports.spawnSaveDatWriter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
let saveDatWriter = null;
|
|
10
|
+
function spawnSaveDatWriter(config) {
|
|
11
|
+
const processName = "saveDatWriter";
|
|
12
|
+
const processDescription = "save#.dat writer";
|
|
13
|
+
const processPath = path_1.default.join(__dirname, processName, processName);
|
|
14
|
+
const modsDataPath = path_1.default.join(config.modsDirectory, "..", "data");
|
|
15
|
+
const watcherModDataPath = path_1.default.join(modsDataPath, constants_1.WATCHER_MOD_NAME);
|
|
16
|
+
const saveDatFileName = `save${config.saveSlot}.dat`;
|
|
17
|
+
const saveDatPath = path_1.default.join(watcherModDataPath, saveDatFileName);
|
|
18
|
+
saveDatWriter = (0, child_process_1.fork)(processPath, [saveDatPath], {
|
|
19
|
+
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
20
|
+
});
|
|
21
|
+
saveDatWriter.on("close", (code) => {
|
|
22
|
+
(0, utils_1.error)(`Error: ${processDescription} subprocess closed with code: ${code}`);
|
|
23
|
+
});
|
|
24
|
+
saveDatWriter.on("exit", (code) => {
|
|
25
|
+
(0, utils_1.error)(`Error: ${processDescription} subprocess exited with code: ${code}`);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.spawnSaveDatWriter = spawnSaveDatWriter;
|
|
29
|
+
function sendMsgToSaveDatWriter(msg) {
|
|
30
|
+
if (saveDatWriter !== null) {
|
|
31
|
+
saveDatWriter.send(msg);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.sendMsgToSaveDatWriter = sendMsgToSaveDatWriter;
|
|
35
35
|
//# sourceMappingURL=spawnSaveDatWriter.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.touchWatcherSaveDatFiles = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
-
const constants_1 = require("../../constants");
|
|
7
|
-
const file = tslib_1.__importStar(require("../../file"));
|
|
8
|
-
function touchWatcherSaveDatFiles(config, verbose) {
|
|
9
|
-
const modsDataPath = path_1.default.join(config.modsDirectory, "..", "data");
|
|
10
|
-
const watcherModDataPath = path_1.default.join(modsDataPath, constants_1.WATCHER_MOD_NAME);
|
|
11
|
-
if (!file.exists(watcherModDataPath, verbose)) {
|
|
12
|
-
file.makeDir(watcherModDataPath, verbose);
|
|
13
|
-
}
|
|
14
|
-
const saveDatFileName = `save${config.saveSlot}.dat`;
|
|
15
|
-
const saveDatPath = path_1.default.join(watcherModDataPath, saveDatFileName);
|
|
16
|
-
if (!file.exists(saveDatPath, verbose)) {
|
|
17
|
-
file.touch(saveDatPath, verbose);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.touchWatcherSaveDatFiles = touchWatcherSaveDatFiles;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.touchWatcherSaveDatFiles = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
const file = tslib_1.__importStar(require("../../file"));
|
|
8
|
+
function touchWatcherSaveDatFiles(config, verbose) {
|
|
9
|
+
const modsDataPath = path_1.default.join(config.modsDirectory, "..", "data");
|
|
10
|
+
const watcherModDataPath = path_1.default.join(modsDataPath, constants_1.WATCHER_MOD_NAME);
|
|
11
|
+
if (!file.exists(watcherModDataPath, verbose)) {
|
|
12
|
+
file.makeDir(watcherModDataPath, verbose);
|
|
13
|
+
}
|
|
14
|
+
const saveDatFileName = `save${config.saveSlot}.dat`;
|
|
15
|
+
const saveDatPath = path_1.default.join(watcherModDataPath, saveDatFileName);
|
|
16
|
+
if (!file.exists(saveDatPath, verbose)) {
|
|
17
|
+
file.touch(saveDatPath, verbose);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.touchWatcherSaveDatFiles = touchWatcherSaveDatFiles;
|
|
21
21
|
//# sourceMappingURL=touchWatcherSaveDatFiles.js.map
|
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.publish = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const constants_1 = require("../../constants");
|
|
8
|
-
const exec_1 = require("../../exec");
|
|
9
|
-
const file = tslib_1.__importStar(require("../../file"));
|
|
10
|
-
const utils_1 = require("../../utils");
|
|
11
|
-
const copy_1 = require("../copy/copy");
|
|
12
|
-
const git_1 = require("../init/git");
|
|
13
|
-
const UPDATE_SCRIPT_NAME = "update.sh";
|
|
14
|
-
function publish(argv, config) {
|
|
15
|
-
const skipVersionIncrement = argv["skip"] === true;
|
|
16
|
-
const setVersion = argv["setVersion"];
|
|
17
|
-
const dryRun = argv["dryRun"] === true;
|
|
18
|
-
const onlyUpload = argv["onlyUpload"] === true;
|
|
19
|
-
const verbose = argv["verbose"] === true;
|
|
20
|
-
const modTargetDirectoryName = (0, utils_1.getModTargetDirectoryName)(config);
|
|
21
|
-
const modTargetPath = path_1.default.join(config.modsDirectory, modTargetDirectoryName);
|
|
22
|
-
validateVersion(setVersion);
|
|
23
|
-
validateGitNotDirty(verbose);
|
|
24
|
-
validateIsaacScriptOtherCopiesNotRunning(verbose);
|
|
25
|
-
if (onlyUpload) {
|
|
26
|
-
uploadMod(modTargetPath, config.steamCmdPath, verbose);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
startPublish(constants_1.MOD_SOURCE_PATH, modTargetPath, skipVersionIncrement, setVersion, config.steamCmdPath, dryRun, verbose);
|
|
30
|
-
}
|
|
31
|
-
exports.publish = publish;
|
|
32
|
-
function validateVersion(setVersion) {
|
|
33
|
-
if (setVersion !== undefined && /^\d+\.\d+\.\d+$/.exec(setVersion) === null) {
|
|
34
|
-
(0, utils_1.error)(chalk_1.default.red(`The version of "${setVersion}" does not match the semantic versioning format.`));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function validateGitNotDirty(verbose) {
|
|
38
|
-
if ((0, git_1.isGitDirty)(verbose)) {
|
|
39
|
-
(0, utils_1.error)(chalk_1.default.red("Before publishing, you must push your current changes to git. (Version commits should be not contain any code changes.)"));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function validateIsaacScriptOtherCopiesNotRunning(verbose) {
|
|
43
|
-
if (process.platform !== "win32") {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
// From: https://securityboulevard.com/2020/01/get-process-list-with-command-line-arguments/
|
|
47
|
-
const stdout = (0, exec_1.execPowershell)("Get-WmiObject Win32_Process -Filter \"name = 'node.exe'\" | Select-Object -ExpandProperty CommandLine", verbose);
|
|
48
|
-
const lines = stdout.split("\r\n");
|
|
49
|
-
const otherCopiesOfRunningIsaacScript = lines.filter((line) => line.includes("node.exe") &&
|
|
50
|
-
line.includes("isaacscript") &&
|
|
51
|
-
!line.includes("isaacscript publish"));
|
|
52
|
-
if (otherCopiesOfRunningIsaacScript.length > 0) {
|
|
53
|
-
(0, utils_1.error)(chalk_1.default.red(`Other copies of ${constants_1.PROJECT_NAME} appear to be running. You must close those copies before publishing.`));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function startPublish(modSourcePath, modTargetPath, skipVersionIncrement, setVersion, steamCmdPath, dryRun, verbose) {
|
|
57
|
-
updateDeps(verbose);
|
|
58
|
-
let version = setVersion === undefined ? getVersionFromPackageJSON(verbose) : setVersion;
|
|
59
|
-
if (!skipVersionIncrement && setVersion === undefined) {
|
|
60
|
-
version = bumpVersionInPackageJSON(version, verbose);
|
|
61
|
-
}
|
|
62
|
-
else if (setVersion !== undefined) {
|
|
63
|
-
writeVersionInPackageJSON(version, verbose);
|
|
64
|
-
}
|
|
65
|
-
writeVersionToConstantsTS(version, verbose);
|
|
66
|
-
writeVersionToMetadataXML(version, verbose);
|
|
67
|
-
writeVersionToVersionTXT(version, verbose);
|
|
68
|
-
runReleaseScriptPreCopy(verbose);
|
|
69
|
-
(0, copy_1.compileAndCopy)(modSourcePath, modTargetPath, verbose);
|
|
70
|
-
purgeRoomXMLs(modTargetPath, verbose);
|
|
71
|
-
runReleaseScriptPostCopy(verbose);
|
|
72
|
-
if (!dryRun) {
|
|
73
|
-
(0, git_1.gitCommitIfChanges)(version, verbose);
|
|
74
|
-
uploadMod(modTargetPath, steamCmdPath, verbose);
|
|
75
|
-
}
|
|
76
|
-
const dryRunSuffix = dryRun ? " (dry run)" : "";
|
|
77
|
-
console.log(`\nPublished version ${version} successfully${dryRunSuffix}.`);
|
|
78
|
-
}
|
|
79
|
-
function updateDeps(verbose) {
|
|
80
|
-
if (!file.exists(UPDATE_SCRIPT_NAME, verbose)) {
|
|
81
|
-
(0, utils_1.error)(`The "${UPDATE_SCRIPT_NAME}" script does not exist in the current working directory.`);
|
|
82
|
-
}
|
|
83
|
-
(0, exec_1.execShell)("bash", [UPDATE_SCRIPT_NAME], verbose);
|
|
84
|
-
}
|
|
85
|
-
function getVersionFromPackageJSON(verbose) {
|
|
86
|
-
if (!file.exists(constants_1.PACKAGE_JSON_PATH, verbose)) {
|
|
87
|
-
(0, utils_1.error)(chalk_1.default.red(`A "${constants_1.PACKAGE_JSON_PATH}" was not found in the current directory.`));
|
|
88
|
-
}
|
|
89
|
-
const packageJSONString = file.read(constants_1.PACKAGE_JSON_PATH, verbose);
|
|
90
|
-
let packageJSON;
|
|
91
|
-
try {
|
|
92
|
-
packageJSON = JSON.parse(packageJSONString);
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
(0, utils_1.error)(`Failed to parse "${chalk_1.default.green(constants_1.PACKAGE_JSON_PATH)}":`, err);
|
|
96
|
-
}
|
|
97
|
-
if (!Object.prototype.hasOwnProperty.call(packageJSON, "version")) {
|
|
98
|
-
(0, utils_1.error)(`The "${chalk_1.default.green(constants_1.PACKAGE_JSON_PATH)}" file does not have a "version" field.`);
|
|
99
|
-
}
|
|
100
|
-
if (typeof packageJSON["version"] !== "string") {
|
|
101
|
-
(0, utils_1.error)(`The "${chalk_1.default.green(constants_1.PACKAGE_JSON_PATH)}" file has a "version" field that is not a string.`);
|
|
102
|
-
}
|
|
103
|
-
return packageJSON["version"];
|
|
104
|
-
}
|
|
105
|
-
function bumpVersionInPackageJSON(version, verbose) {
|
|
106
|
-
// Get the patch version (i.e. the third number)
|
|
107
|
-
const [majorVersion, minorVersion, patchVersion] = (0, utils_1.parseSemVer)(version);
|
|
108
|
-
const incrementedPatchVersion = patchVersion + 1;
|
|
109
|
-
const incrementedVersion = `${majorVersion}.${minorVersion}.${incrementedPatchVersion}`;
|
|
110
|
-
const packageJSON = file.read(constants_1.PACKAGE_JSON_PATH, verbose);
|
|
111
|
-
const newPackageJSON = packageJSON.replace(/"version": ".+",/, `"version": "${incrementedVersion}",`);
|
|
112
|
-
file.write(constants_1.PACKAGE_JSON_PATH, newPackageJSON, verbose);
|
|
113
|
-
console.log(`The version of ${incrementedVersion} was written to: ${constants_1.PACKAGE_JSON_PATH}`);
|
|
114
|
-
return incrementedVersion;
|
|
115
|
-
}
|
|
116
|
-
function writeVersionInPackageJSON(version, verbose) {
|
|
117
|
-
const packageJSON = file.read(constants_1.PACKAGE_JSON_PATH, verbose);
|
|
118
|
-
const newPackageJSON = packageJSON.replace(/"version": ".+",/, `"version": "${version}",`);
|
|
119
|
-
file.write(constants_1.PACKAGE_JSON_PATH, newPackageJSON, verbose);
|
|
120
|
-
console.log(`The version of ${version} was written to: ${constants_1.PACKAGE_JSON_PATH}`);
|
|
121
|
-
}
|
|
122
|
-
function writeVersionToConstantsTS(version, verbose) {
|
|
123
|
-
if (!file.exists(constants_1.CONSTANTS_TS_PATH, verbose)) {
|
|
124
|
-
console.log('Skipping writing the version to "constants.ts" since it was not found.');
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const constantsTS = file.read(constants_1.CONSTANTS_TS_PATH, verbose);
|
|
128
|
-
const newConstantsTS = constantsTS.replace(/const VERSION = ".+"/, `const VERSION = "${version}"`);
|
|
129
|
-
file.write(constants_1.CONSTANTS_TS_PATH, newConstantsTS, verbose);
|
|
130
|
-
console.log(`The version of ${version} was written to: ${constants_1.CONSTANTS_TS_PATH}`);
|
|
131
|
-
}
|
|
132
|
-
function writeVersionToMetadataXML(version, verbose) {
|
|
133
|
-
const metadataXML = file.read(constants_1.METADATA_XML_PATH, verbose);
|
|
134
|
-
const newMetadataXML = metadataXML.replace(/<version>.+<\/version>/, `<version>${version}</version>`);
|
|
135
|
-
file.write(constants_1.METADATA_XML_PATH, newMetadataXML, verbose);
|
|
136
|
-
console.log(`The version of ${version} was written to: ${constants_1.METADATA_XML_PATH}`);
|
|
137
|
-
}
|
|
138
|
-
function writeVersionToVersionTXT(version, verbose) {
|
|
139
|
-
file.write(constants_1.VERSION_TXT_PATH, version, verbose);
|
|
140
|
-
console.log(`The version of ${version} was written to: ${constants_1.VERSION_TXT_PATH}`);
|
|
141
|
-
}
|
|
142
|
-
function runReleaseScriptPreCopy(verbose) {
|
|
143
|
-
if (!file.exists(constants_1.PUBLISH_PRE_COPY_PY_PATH, verbose)) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
console.log(`Running the "${constants_1.PUBLISH_PRE_COPY_PY_PATH}" script.`);
|
|
147
|
-
let [, stdout] = (0, exec_1.execShell)("python", [constants_1.PUBLISH_PRE_COPY_PY_PATH], verbose);
|
|
148
|
-
stdout = stdout.trim();
|
|
149
|
-
if (stdout.length > 0) {
|
|
150
|
-
console.log(stdout);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function runReleaseScriptPostCopy(verbose) {
|
|
154
|
-
if (!file.exists(constants_1.PUBLISH_POST_COPY_PY_PATH, verbose)) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
console.log(`Running the "${constants_1.PUBLISH_POST_COPY_PY_PATH}" script.`);
|
|
158
|
-
let [, stdout] = (0, exec_1.execShell)("python", [constants_1.PUBLISH_POST_COPY_PY_PATH], verbose);
|
|
159
|
-
stdout = stdout.trim();
|
|
160
|
-
if (stdout.length > 0) {
|
|
161
|
-
console.log(stdout);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function purgeRoomXMLs(modTargetPath, verbose) {
|
|
165
|
-
const roomsPath = path_1.default.join(modTargetPath, "resources", "rooms");
|
|
166
|
-
if (!file.exists(roomsPath, verbose) || !file.isDir(roomsPath, verbose)) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
const roomFileList = file.getDirList(roomsPath, verbose);
|
|
170
|
-
roomFileList.forEach((fileName) => {
|
|
171
|
-
if (path_1.default.extname(fileName) === ".xml") {
|
|
172
|
-
const roomFilePath = path_1.default.join(roomsPath, fileName);
|
|
173
|
-
file.deleteFileOrDirectory(roomFilePath, verbose);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
function uploadMod(modTargetPath, steamCmdPath, verbose) {
|
|
178
|
-
if (steamCmdPath === undefined) {
|
|
179
|
-
console.log(`The "steamCmdPath" property was not found in the "${chalk_1.default.green(constants_1.CONFIG_FILE_NAME)}" file; assuming that we want to use the ModUploader tool.`);
|
|
180
|
-
(0, exec_1.execExe)(constants_1.MOD_UPLOADER_PATH, verbose, modTargetPath);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
runSteamCmd(modTargetPath, steamCmdPath, verbose);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function runSteamCmd(modTargetPath, steamCmdPath, verbose) {
|
|
187
|
-
if (!file.exists(steamCmdPath, verbose)) {
|
|
188
|
-
(0, utils_1.error)(chalk_1.default.red(`The path provided for "steamCmdPath" is "${steamCmdPath}", but that does not exist.`));
|
|
189
|
-
}
|
|
190
|
-
const metadataVDFPath = path_1.default.join(modTargetPath, "metadata.vdf");
|
|
191
|
-
if (!file.exists(metadataVDFPath, verbose)) {
|
|
192
|
-
console.error(chalk_1.default.red(`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 ${constants_1.PROJECT_NAME} docs:`));
|
|
193
|
-
(0, utils_1.error)(getIsaacScriptDocs());
|
|
194
|
-
}
|
|
195
|
-
const usernameVar = "STEAM_USERNAME";
|
|
196
|
-
const username = process.env[usernameVar];
|
|
197
|
-
if (username === undefined || username === "") {
|
|
198
|
-
console.error(chalk_1.default.red(`Failed to read the "${usernameVar}" environment variable from the ".env" file. Please see the ${constants_1.PROJECT_NAME} docs:`));
|
|
199
|
-
(0, utils_1.error)(getIsaacScriptDocs());
|
|
200
|
-
}
|
|
201
|
-
const passwordVar = "STEAM_PASSWORD";
|
|
202
|
-
const password = process.env[passwordVar];
|
|
203
|
-
if (password === undefined || password === "") {
|
|
204
|
-
console.error(chalk_1.default.red(`Failed to read the "${passwordVar}" environment variable from the ".env" file. Please see the ${constants_1.PROJECT_NAME} docs:`));
|
|
205
|
-
(0, utils_1.error)(getIsaacScriptDocs());
|
|
206
|
-
}
|
|
207
|
-
console.log("Uploading the mod to the Steam Workshop...");
|
|
208
|
-
(0, exec_1.execShell)(steamCmdPath, [
|
|
209
|
-
"+login",
|
|
210
|
-
username,
|
|
211
|
-
password,
|
|
212
|
-
"+workshop_build_item",
|
|
213
|
-
metadataVDFPath,
|
|
214
|
-
"+quit",
|
|
215
|
-
], verbose);
|
|
216
|
-
console.log("Mod uploaded successfully.");
|
|
217
|
-
}
|
|
218
|
-
function getIsaacScriptDocs() {
|
|
219
|
-
return chalk_1.default.red("https://isaacscript.github.io/docs/publishing-to-the-workshop/#metadatavdf");
|
|
220
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publish = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
|
+
const exec_1 = require("../../exec");
|
|
9
|
+
const file = tslib_1.__importStar(require("../../file"));
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
11
|
+
const copy_1 = require("../copy/copy");
|
|
12
|
+
const git_1 = require("../init/git");
|
|
13
|
+
const UPDATE_SCRIPT_NAME = "update.sh";
|
|
14
|
+
function publish(argv, config) {
|
|
15
|
+
const skipVersionIncrement = argv["skip"] === true;
|
|
16
|
+
const setVersion = argv["setVersion"];
|
|
17
|
+
const dryRun = argv["dryRun"] === true;
|
|
18
|
+
const onlyUpload = argv["onlyUpload"] === true;
|
|
19
|
+
const verbose = argv["verbose"] === true;
|
|
20
|
+
const modTargetDirectoryName = (0, utils_1.getModTargetDirectoryName)(config);
|
|
21
|
+
const modTargetPath = path_1.default.join(config.modsDirectory, modTargetDirectoryName);
|
|
22
|
+
validateVersion(setVersion);
|
|
23
|
+
validateGitNotDirty(verbose);
|
|
24
|
+
validateIsaacScriptOtherCopiesNotRunning(verbose);
|
|
25
|
+
if (onlyUpload) {
|
|
26
|
+
uploadMod(modTargetPath, config.steamCmdPath, verbose);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
startPublish(constants_1.MOD_SOURCE_PATH, modTargetPath, skipVersionIncrement, setVersion, config.steamCmdPath, dryRun, verbose);
|
|
30
|
+
}
|
|
31
|
+
exports.publish = publish;
|
|
32
|
+
function validateVersion(setVersion) {
|
|
33
|
+
if (setVersion !== undefined && /^\d+\.\d+\.\d+$/.exec(setVersion) === null) {
|
|
34
|
+
(0, utils_1.error)(chalk_1.default.red(`The version of "${setVersion}" does not match the semantic versioning format.`));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function validateGitNotDirty(verbose) {
|
|
38
|
+
if ((0, git_1.isGitDirty)(verbose)) {
|
|
39
|
+
(0, utils_1.error)(chalk_1.default.red("Before publishing, you must push your current changes to git. (Version commits should be not contain any code changes.)"));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function validateIsaacScriptOtherCopiesNotRunning(verbose) {
|
|
43
|
+
if (process.platform !== "win32") {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// From: https://securityboulevard.com/2020/01/get-process-list-with-command-line-arguments/
|
|
47
|
+
const stdout = (0, exec_1.execPowershell)("Get-WmiObject Win32_Process -Filter \"name = 'node.exe'\" | Select-Object -ExpandProperty CommandLine", verbose);
|
|
48
|
+
const lines = stdout.split("\r\n");
|
|
49
|
+
const otherCopiesOfRunningIsaacScript = lines.filter((line) => line.includes("node.exe") &&
|
|
50
|
+
line.includes("isaacscript") &&
|
|
51
|
+
!line.includes("isaacscript publish"));
|
|
52
|
+
if (otherCopiesOfRunningIsaacScript.length > 0) {
|
|
53
|
+
(0, utils_1.error)(chalk_1.default.red(`Other copies of ${constants_1.PROJECT_NAME} appear to be running. You must close those copies before publishing.`));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function startPublish(modSourcePath, modTargetPath, skipVersionIncrement, setVersion, steamCmdPath, dryRun, verbose) {
|
|
57
|
+
updateDeps(verbose);
|
|
58
|
+
let version = setVersion === undefined ? getVersionFromPackageJSON(verbose) : setVersion;
|
|
59
|
+
if (!skipVersionIncrement && setVersion === undefined) {
|
|
60
|
+
version = bumpVersionInPackageJSON(version, verbose);
|
|
61
|
+
}
|
|
62
|
+
else if (setVersion !== undefined) {
|
|
63
|
+
writeVersionInPackageJSON(version, verbose);
|
|
64
|
+
}
|
|
65
|
+
writeVersionToConstantsTS(version, verbose);
|
|
66
|
+
writeVersionToMetadataXML(version, verbose);
|
|
67
|
+
writeVersionToVersionTXT(version, verbose);
|
|
68
|
+
runReleaseScriptPreCopy(verbose);
|
|
69
|
+
(0, copy_1.compileAndCopy)(modSourcePath, modTargetPath, verbose);
|
|
70
|
+
purgeRoomXMLs(modTargetPath, verbose);
|
|
71
|
+
runReleaseScriptPostCopy(verbose);
|
|
72
|
+
if (!dryRun) {
|
|
73
|
+
(0, git_1.gitCommitIfChanges)(version, verbose);
|
|
74
|
+
uploadMod(modTargetPath, steamCmdPath, verbose);
|
|
75
|
+
}
|
|
76
|
+
const dryRunSuffix = dryRun ? " (dry run)" : "";
|
|
77
|
+
console.log(`\nPublished version ${version} successfully${dryRunSuffix}.`);
|
|
78
|
+
}
|
|
79
|
+
function updateDeps(verbose) {
|
|
80
|
+
if (!file.exists(UPDATE_SCRIPT_NAME, verbose)) {
|
|
81
|
+
(0, utils_1.error)(`The "${UPDATE_SCRIPT_NAME}" script does not exist in the current working directory.`);
|
|
82
|
+
}
|
|
83
|
+
(0, exec_1.execShell)("bash", [UPDATE_SCRIPT_NAME], verbose);
|
|
84
|
+
}
|
|
85
|
+
function getVersionFromPackageJSON(verbose) {
|
|
86
|
+
if (!file.exists(constants_1.PACKAGE_JSON_PATH, verbose)) {
|
|
87
|
+
(0, utils_1.error)(chalk_1.default.red(`A "${constants_1.PACKAGE_JSON_PATH}" was not found in the current directory.`));
|
|
88
|
+
}
|
|
89
|
+
const packageJSONString = file.read(constants_1.PACKAGE_JSON_PATH, verbose);
|
|
90
|
+
let packageJSON;
|
|
91
|
+
try {
|
|
92
|
+
packageJSON = JSON.parse(packageJSONString);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
(0, utils_1.error)(`Failed to parse "${chalk_1.default.green(constants_1.PACKAGE_JSON_PATH)}":`, err);
|
|
96
|
+
}
|
|
97
|
+
if (!Object.prototype.hasOwnProperty.call(packageJSON, "version")) {
|
|
98
|
+
(0, utils_1.error)(`The "${chalk_1.default.green(constants_1.PACKAGE_JSON_PATH)}" file does not have a "version" field.`);
|
|
99
|
+
}
|
|
100
|
+
if (typeof packageJSON["version"] !== "string") {
|
|
101
|
+
(0, utils_1.error)(`The "${chalk_1.default.green(constants_1.PACKAGE_JSON_PATH)}" file has a "version" field that is not a string.`);
|
|
102
|
+
}
|
|
103
|
+
return packageJSON["version"];
|
|
104
|
+
}
|
|
105
|
+
function bumpVersionInPackageJSON(version, verbose) {
|
|
106
|
+
// Get the patch version (i.e. the third number)
|
|
107
|
+
const [majorVersion, minorVersion, patchVersion] = (0, utils_1.parseSemVer)(version);
|
|
108
|
+
const incrementedPatchVersion = patchVersion + 1;
|
|
109
|
+
const incrementedVersion = `${majorVersion}.${minorVersion}.${incrementedPatchVersion}`;
|
|
110
|
+
const packageJSON = file.read(constants_1.PACKAGE_JSON_PATH, verbose);
|
|
111
|
+
const newPackageJSON = packageJSON.replace(/"version": ".+",/, `"version": "${incrementedVersion}",`);
|
|
112
|
+
file.write(constants_1.PACKAGE_JSON_PATH, newPackageJSON, verbose);
|
|
113
|
+
console.log(`The version of ${incrementedVersion} was written to: ${constants_1.PACKAGE_JSON_PATH}`);
|
|
114
|
+
return incrementedVersion;
|
|
115
|
+
}
|
|
116
|
+
function writeVersionInPackageJSON(version, verbose) {
|
|
117
|
+
const packageJSON = file.read(constants_1.PACKAGE_JSON_PATH, verbose);
|
|
118
|
+
const newPackageJSON = packageJSON.replace(/"version": ".+",/, `"version": "${version}",`);
|
|
119
|
+
file.write(constants_1.PACKAGE_JSON_PATH, newPackageJSON, verbose);
|
|
120
|
+
console.log(`The version of ${version} was written to: ${constants_1.PACKAGE_JSON_PATH}`);
|
|
121
|
+
}
|
|
122
|
+
function writeVersionToConstantsTS(version, verbose) {
|
|
123
|
+
if (!file.exists(constants_1.CONSTANTS_TS_PATH, verbose)) {
|
|
124
|
+
console.log('Skipping writing the version to "constants.ts" since it was not found.');
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const constantsTS = file.read(constants_1.CONSTANTS_TS_PATH, verbose);
|
|
128
|
+
const newConstantsTS = constantsTS.replace(/const VERSION = ".+"/, `const VERSION = "${version}"`);
|
|
129
|
+
file.write(constants_1.CONSTANTS_TS_PATH, newConstantsTS, verbose);
|
|
130
|
+
console.log(`The version of ${version} was written to: ${constants_1.CONSTANTS_TS_PATH}`);
|
|
131
|
+
}
|
|
132
|
+
function writeVersionToMetadataXML(version, verbose) {
|
|
133
|
+
const metadataXML = file.read(constants_1.METADATA_XML_PATH, verbose);
|
|
134
|
+
const newMetadataXML = metadataXML.replace(/<version>.+<\/version>/, `<version>${version}</version>`);
|
|
135
|
+
file.write(constants_1.METADATA_XML_PATH, newMetadataXML, verbose);
|
|
136
|
+
console.log(`The version of ${version} was written to: ${constants_1.METADATA_XML_PATH}`);
|
|
137
|
+
}
|
|
138
|
+
function writeVersionToVersionTXT(version, verbose) {
|
|
139
|
+
file.write(constants_1.VERSION_TXT_PATH, version, verbose);
|
|
140
|
+
console.log(`The version of ${version} was written to: ${constants_1.VERSION_TXT_PATH}`);
|
|
141
|
+
}
|
|
142
|
+
function runReleaseScriptPreCopy(verbose) {
|
|
143
|
+
if (!file.exists(constants_1.PUBLISH_PRE_COPY_PY_PATH, verbose)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
console.log(`Running the "${constants_1.PUBLISH_PRE_COPY_PY_PATH}" script.`);
|
|
147
|
+
let [, stdout] = (0, exec_1.execShell)("python", [constants_1.PUBLISH_PRE_COPY_PY_PATH], verbose);
|
|
148
|
+
stdout = stdout.trim();
|
|
149
|
+
if (stdout.length > 0) {
|
|
150
|
+
console.log(stdout);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function runReleaseScriptPostCopy(verbose) {
|
|
154
|
+
if (!file.exists(constants_1.PUBLISH_POST_COPY_PY_PATH, verbose)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
console.log(`Running the "${constants_1.PUBLISH_POST_COPY_PY_PATH}" script.`);
|
|
158
|
+
let [, stdout] = (0, exec_1.execShell)("python", [constants_1.PUBLISH_POST_COPY_PY_PATH], verbose);
|
|
159
|
+
stdout = stdout.trim();
|
|
160
|
+
if (stdout.length > 0) {
|
|
161
|
+
console.log(stdout);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function purgeRoomXMLs(modTargetPath, verbose) {
|
|
165
|
+
const roomsPath = path_1.default.join(modTargetPath, "resources", "rooms");
|
|
166
|
+
if (!file.exists(roomsPath, verbose) || !file.isDir(roomsPath, verbose)) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const roomFileList = file.getDirList(roomsPath, verbose);
|
|
170
|
+
roomFileList.forEach((fileName) => {
|
|
171
|
+
if (path_1.default.extname(fileName) === ".xml") {
|
|
172
|
+
const roomFilePath = path_1.default.join(roomsPath, fileName);
|
|
173
|
+
file.deleteFileOrDirectory(roomFilePath, verbose);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function uploadMod(modTargetPath, steamCmdPath, verbose) {
|
|
178
|
+
if (steamCmdPath === undefined) {
|
|
179
|
+
console.log(`The "steamCmdPath" property was not found in the "${chalk_1.default.green(constants_1.CONFIG_FILE_NAME)}" file; assuming that we want to use the ModUploader tool.`);
|
|
180
|
+
(0, exec_1.execExe)(constants_1.MOD_UPLOADER_PATH, verbose, modTargetPath);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
runSteamCmd(modTargetPath, steamCmdPath, verbose);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function runSteamCmd(modTargetPath, steamCmdPath, verbose) {
|
|
187
|
+
if (!file.exists(steamCmdPath, verbose)) {
|
|
188
|
+
(0, utils_1.error)(chalk_1.default.red(`The path provided for "steamCmdPath" is "${steamCmdPath}", but that does not exist.`));
|
|
189
|
+
}
|
|
190
|
+
const metadataVDFPath = path_1.default.join(modTargetPath, "metadata.vdf");
|
|
191
|
+
if (!file.exists(metadataVDFPath, verbose)) {
|
|
192
|
+
console.error(chalk_1.default.red(`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 ${constants_1.PROJECT_NAME} docs:`));
|
|
193
|
+
(0, utils_1.error)(getIsaacScriptDocs());
|
|
194
|
+
}
|
|
195
|
+
const usernameVar = "STEAM_USERNAME";
|
|
196
|
+
const username = process.env[usernameVar];
|
|
197
|
+
if (username === undefined || username === "") {
|
|
198
|
+
console.error(chalk_1.default.red(`Failed to read the "${usernameVar}" environment variable from the ".env" file. Please see the ${constants_1.PROJECT_NAME} docs:`));
|
|
199
|
+
(0, utils_1.error)(getIsaacScriptDocs());
|
|
200
|
+
}
|
|
201
|
+
const passwordVar = "STEAM_PASSWORD";
|
|
202
|
+
const password = process.env[passwordVar];
|
|
203
|
+
if (password === undefined || password === "") {
|
|
204
|
+
console.error(chalk_1.default.red(`Failed to read the "${passwordVar}" environment variable from the ".env" file. Please see the ${constants_1.PROJECT_NAME} docs:`));
|
|
205
|
+
(0, utils_1.error)(getIsaacScriptDocs());
|
|
206
|
+
}
|
|
207
|
+
console.log("Uploading the mod to the Steam Workshop...");
|
|
208
|
+
(0, exec_1.execShell)(steamCmdPath, [
|
|
209
|
+
"+login",
|
|
210
|
+
username,
|
|
211
|
+
password,
|
|
212
|
+
"+workshop_build_item",
|
|
213
|
+
metadataVDFPath,
|
|
214
|
+
"+quit",
|
|
215
|
+
], verbose);
|
|
216
|
+
console.log("Mod uploaded successfully.");
|
|
217
|
+
}
|
|
218
|
+
function getIsaacScriptDocs() {
|
|
219
|
+
return chalk_1.default.red("https://isaacscript.github.io/docs/publishing-to-the-workshop/#metadatavdf");
|
|
220
|
+
}
|
|
221
221
|
//# sourceMappingURL=publish.js.map
|