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
package/src/configFile.js
CHANGED
|
@@ -1,66 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFile = exports.createObject = exports.get = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
-
const JSONC = tslib_1.__importStar(require("jsonc-parser"));
|
|
7
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
-
const getModsDir_1 = require("./commands/init/getModsDir");
|
|
9
|
-
const promptSaveSlot_1 = require("./commands/init/promptSaveSlot");
|
|
10
|
-
const constants_1 = require("./constants");
|
|
11
|
-
const file = tslib_1.__importStar(require("./file"));
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
function get(argv) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
exports.createFile = createFile;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFile = exports.createObject = exports.get = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const JSONC = tslib_1.__importStar(require("jsonc-parser"));
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const getModsDir_1 = require("./commands/init/getModsDir");
|
|
9
|
+
const promptSaveSlot_1 = require("./commands/init/promptSaveSlot");
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
const file = tslib_1.__importStar(require("./file"));
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
async function get(argv) {
|
|
14
|
+
const verbose = argv["verbose"] === true;
|
|
15
|
+
const yes = argv["yes"] === true;
|
|
16
|
+
const existingConfig = readExistingConfig(verbose);
|
|
17
|
+
if (existingConfig !== undefined) {
|
|
18
|
+
return existingConfig;
|
|
19
|
+
}
|
|
20
|
+
// No config file exists, so prompt the user for some information and create one.
|
|
21
|
+
const modsDirectory = await (0, getModsDir_1.getModsDir)(argv, verbose);
|
|
22
|
+
const saveSlot = await (0, promptSaveSlot_1.promptSaveSlot)(argv, yes);
|
|
23
|
+
const config = createObject(modsDirectory, saveSlot);
|
|
24
|
+
createFile(constants_1.CWD, config, verbose);
|
|
25
|
+
return config;
|
|
26
|
+
}
|
|
27
|
+
exports.get = get;
|
|
28
|
+
function readExistingConfig(verbose) {
|
|
29
|
+
if (!file.exists(constants_1.CONFIG_FILE_PATH, verbose)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const configRaw = file.read(constants_1.CONFIG_FILE_PATH, verbose);
|
|
33
|
+
let config;
|
|
34
|
+
try {
|
|
35
|
+
config = JSONC.parse(configRaw);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
(0, utils_1.error)(`Failed to parse the "${chalk_1.default.green(constants_1.CONFIG_FILE_PATH)}" file:`, err);
|
|
39
|
+
}
|
|
40
|
+
if (config.modsDirectory === undefined) {
|
|
41
|
+
errorMissing("modsDirectory", "This should be equal to the directory where Isaac mods live on your system.");
|
|
42
|
+
}
|
|
43
|
+
if (config.saveSlot === undefined) {
|
|
44
|
+
errorMissing("saveSlot", "This should be equal to the save slot that you test your mods on.");
|
|
45
|
+
}
|
|
46
|
+
return config;
|
|
47
|
+
}
|
|
48
|
+
function errorMissing(field, description) {
|
|
49
|
+
(0, utils_1.error)(`The "${constants_1.CONFIG_FILE_NAME}" file is missing a "${field}" value. ${description} Please add it.`);
|
|
50
|
+
}
|
|
51
|
+
function createObject(modsDirectory, saveSlot) {
|
|
52
|
+
return {
|
|
53
|
+
modsDirectory,
|
|
54
|
+
saveSlot,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.createObject = createObject;
|
|
58
|
+
function createFile(projectPath, config, verbose) {
|
|
59
|
+
const configFilePath = path_1.default.join(projectPath, constants_1.CONFIG_FILE_NAME);
|
|
60
|
+
const configContents = JSON.stringify(config, null, 2);
|
|
61
|
+
file.write(configFilePath, configContents, verbose);
|
|
62
|
+
}
|
|
63
|
+
exports.createFile = createFile;
|
|
66
64
|
//# sourceMappingURL=configFile.js.map
|
package/src/configFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configFile.js","sourceRoot":"","sources":["../../../../packages/isaacscript-cli/src/configFile.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,4DAAsC;AACtC,wDAAwB;AACxB,2DAAwD;AACxD,mEAAgE;AAChE,2CAAsE;AACtE,qDAA+B;AAE/B,mCAAgC;
|
|
1
|
+
{"version":3,"file":"configFile.js","sourceRoot":"","sources":["../../../../packages/isaacscript-cli/src/configFile.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,4DAAsC;AACtC,wDAAwB;AACxB,2DAAwD;AACxD,mEAAgE;AAChE,2CAAsE;AACtE,qDAA+B;AAE/B,mCAAgC;AAEzB,KAAK,UAAU,GAAG,CAAC,IAA6B;IACrD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAEjC,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,cAAc,KAAK,SAAS,EAAE;QAChC,OAAO,cAAc,CAAC;KACvB;IAED,iFAAiF;IACjF,MAAM,aAAa,GAAG,MAAM,IAAA,uBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,IAAA,+BAAc,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,YAAY,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACrD,UAAU,CAAC,eAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,OAAO,MAAM,CAAC;AAChB,CAAC;AAhBD,kBAgBC;AAED,SAAS,kBAAkB,CAAC,OAAgB;IAC1C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,4BAAgB,EAAE,OAAO,CAAC,EAAE;QAC3C,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,4BAAgB,EAAE,OAAO,CAAC,CAAC;IACvD,IAAI,MAAc,CAAC;IACnB,IAAI;QACF,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAW,CAAC;KAC3C;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,aAAK,EAAC,wBAAwB,eAAK,CAAC,KAAK,CAAC,4BAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;KAC5E;IAED,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE;QACtC,YAAY,CACV,eAAe,EACf,6EAA6E,CAC9E,CAAC;KACH;IAED,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE;QACjC,YAAY,CACV,UAAU,EACV,mEAAmE,CACpE,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,KAAa,EAAE,WAAmB;IACtD,IAAA,aAAK,EACH,QAAQ,4BAAgB,wBAAwB,KAAK,YAAY,WAAW,iBAAiB,CAC9F,CAAC;AACJ,CAAC;AAED,SAAgB,YAAY,CAAC,aAAqB,EAAE,QAAgB;IAClE,OAAO;QACL,aAAa;QACb,QAAQ;KACT,CAAC;AACJ,CAAC;AALD,oCAKC;AAED,SAAgB,UAAU,CACxB,WAAmB,EACnB,MAAc,EACd,OAAgB;IAEhB,MAAM,cAAc,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,4BAAgB,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AARD,gCAQC"}
|
package/src/constants.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PUBLISH_POST_COPY_PY_PATH = exports.PUBLISH_PRE_COPY_PY_PATH = exports.VERSION_TXT_PATH = exports.METADATA_XML_PATH = exports.MAIN_LUA = exports.MOD_SOURCE_PATH = exports.YARN_LOCK_PATH = exports.CONSTANTS_TS_PATH = exports.PACKAGE_JSON_PATH = exports.TSCONFIG_PATH = exports.CONFIG_FILE_PATH = exports.CONFIG_FILE_NAME = exports.README_MD_TEMPLATES_PATH = exports.README_MD = exports.PACKAGE_JSON_TEMPLATE_PATH = exports.PACKAGE_JSON = exports.METADATA_VDF_TEMPLATE_PATH = exports.METADATA_VDF = exports.METADATA_XML_TEMPLATE_PATH = exports.METADATA_XML = exports.MAIN_TS_TEMPLATE_PATH = exports.MAIN_TS = exports.GITIGNORE_TEMPLATE_PATH = exports.GITIGNORE = exports.TEMPLATES_STATIC_DIR = exports.WATCHER_MOD_SOURCE_PATH = exports.WATCHER_MOD_NAME = exports.DISABLE_IT_FILE = exports.PROJECT_NAME = exports.MOD_UPLOADER_PATH = exports.FILE_SYNCED_MESSAGE = exports.HOME_DIR = exports.CWD = exports.CURRENT_DIRECTORY_NAME = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const cwd = process.cwd();
|
|
8
|
-
/**
|
|
9
|
-
* From:
|
|
10
|
-
* https://stackoverflow.com/questions/9080085/node-js-find-home-directory-in-platform-agnostic-way
|
|
11
|
-
*/
|
|
12
|
-
const homeDir = os_1.default.homedir();
|
|
13
|
-
// Miscellaneous
|
|
14
|
-
exports.CURRENT_DIRECTORY_NAME = path_1.default.basename(cwd);
|
|
15
|
-
exports.CWD = cwd;
|
|
16
|
-
exports.HOME_DIR = homeDir;
|
|
17
|
-
exports.FILE_SYNCED_MESSAGE = "File synced:";
|
|
18
|
-
exports.MOD_UPLOADER_PATH = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\tools\\ModUploader\\ModUploader.exe";
|
|
19
|
-
exports.PROJECT_NAME = "IsaacScript";
|
|
20
|
-
// `isaacscript`
|
|
21
|
-
const REPO_ROOT = path_1.default.join(__dirname, "..");
|
|
22
|
-
// `isaacscript/isaacscript-watcher`
|
|
23
|
-
exports.DISABLE_IT_FILE = "disable.it";
|
|
24
|
-
exports.WATCHER_MOD_NAME = "isaacscript-watcher";
|
|
25
|
-
exports.WATCHER_MOD_SOURCE_PATH = path_1.default.join(REPO_ROOT, exports.WATCHER_MOD_NAME);
|
|
26
|
-
// `isaacscript/file-templates`
|
|
27
|
-
const TEMPLATES_DIR = path_1.default.join(REPO_ROOT, "file-templates");
|
|
28
|
-
// `isaacscript/file-templates/static`
|
|
29
|
-
exports.TEMPLATES_STATIC_DIR = path_1.default.join(TEMPLATES_DIR, "static");
|
|
30
|
-
// `isaacscript/file-templates/dynamic`
|
|
31
|
-
const TEMPLATES_DYNAMIC_DIR = path_1.default.join(TEMPLATES_DIR, "dynamic");
|
|
32
|
-
exports.GITIGNORE = "gitignore"; // Not named ".gitignore" to prevent NPM from deleting it
|
|
33
|
-
exports.GITIGNORE_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.GITIGNORE);
|
|
34
|
-
exports.MAIN_TS = "main.ts";
|
|
35
|
-
exports.MAIN_TS_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.MAIN_TS);
|
|
36
|
-
exports.METADATA_XML = "metadata.xml";
|
|
37
|
-
exports.METADATA_XML_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.METADATA_XML);
|
|
38
|
-
exports.METADATA_VDF = "metadata.vdf";
|
|
39
|
-
exports.METADATA_VDF_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.METADATA_VDF);
|
|
40
|
-
exports.PACKAGE_JSON = "package.json";
|
|
41
|
-
exports.PACKAGE_JSON_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.PACKAGE_JSON);
|
|
42
|
-
exports.README_MD = "README.md";
|
|
43
|
-
exports.README_MD_TEMPLATES_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.README_MD);
|
|
44
|
-
// `project`
|
|
45
|
-
exports.CONFIG_FILE_NAME = "isaacscript.json";
|
|
46
|
-
exports.CONFIG_FILE_PATH = path_1.default.join(exports.CWD, exports.CONFIG_FILE_NAME);
|
|
47
|
-
exports.TSCONFIG_PATH = path_1.default.join(exports.CWD, "tsconfig.json");
|
|
48
|
-
exports.PACKAGE_JSON_PATH = path_1.default.join(exports.CWD, "package.json");
|
|
49
|
-
exports.CONSTANTS_TS_PATH = path_1.default.join(exports.CWD, "src", "constants.ts");
|
|
50
|
-
exports.YARN_LOCK_PATH = path_1.default.join(exports.CWD, "yarn.lock");
|
|
51
|
-
// `project/mod`
|
|
52
|
-
exports.MOD_SOURCE_PATH = path_1.default.join(exports.CWD, "mod");
|
|
53
|
-
exports.MAIN_LUA = "main.lua";
|
|
54
|
-
exports.METADATA_XML_PATH = path_1.default.join(exports.MOD_SOURCE_PATH, "metadata.xml");
|
|
55
|
-
exports.VERSION_TXT_PATH = path_1.default.join(exports.MOD_SOURCE_PATH, "version.txt");
|
|
56
|
-
// `project/scripts`
|
|
57
|
-
const SCRIPTS_PATH = path_1.default.join(exports.CWD, "scripts");
|
|
58
|
-
exports.PUBLISH_PRE_COPY_PY_PATH = path_1.default.join(SCRIPTS_PATH, "publish_pre_copy.py");
|
|
59
|
-
exports.PUBLISH_POST_COPY_PY_PATH = path_1.default.join(SCRIPTS_PATH, "publish_post_copy.py");
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PUBLISH_POST_COPY_PY_PATH = exports.PUBLISH_PRE_COPY_PY_PATH = exports.VERSION_TXT_PATH = exports.METADATA_XML_PATH = exports.MAIN_LUA = exports.MOD_SOURCE_PATH = exports.YARN_LOCK_PATH = exports.CONSTANTS_TS_PATH = exports.PACKAGE_JSON_PATH = exports.TSCONFIG_PATH = exports.CONFIG_FILE_PATH = exports.CONFIG_FILE_NAME = exports.README_MD_TEMPLATES_PATH = exports.README_MD = exports.PACKAGE_JSON_TEMPLATE_PATH = exports.PACKAGE_JSON = exports.METADATA_VDF_TEMPLATE_PATH = exports.METADATA_VDF = exports.METADATA_XML_TEMPLATE_PATH = exports.METADATA_XML = exports.MAIN_TS_TEMPLATE_PATH = exports.MAIN_TS = exports.GITIGNORE_TEMPLATE_PATH = exports.GITIGNORE = exports.TEMPLATES_STATIC_DIR = exports.WATCHER_MOD_SOURCE_PATH = exports.WATCHER_MOD_NAME = exports.DISABLE_IT_FILE = exports.PROJECT_NAME = exports.MOD_UPLOADER_PATH = exports.FILE_SYNCED_MESSAGE = exports.HOME_DIR = exports.CWD = exports.CURRENT_DIRECTORY_NAME = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
/**
|
|
9
|
+
* From:
|
|
10
|
+
* https://stackoverflow.com/questions/9080085/node-js-find-home-directory-in-platform-agnostic-way
|
|
11
|
+
*/
|
|
12
|
+
const homeDir = os_1.default.homedir();
|
|
13
|
+
// Miscellaneous
|
|
14
|
+
exports.CURRENT_DIRECTORY_NAME = path_1.default.basename(cwd);
|
|
15
|
+
exports.CWD = cwd;
|
|
16
|
+
exports.HOME_DIR = homeDir;
|
|
17
|
+
exports.FILE_SYNCED_MESSAGE = "File synced:";
|
|
18
|
+
exports.MOD_UPLOADER_PATH = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\tools\\ModUploader\\ModUploader.exe";
|
|
19
|
+
exports.PROJECT_NAME = "IsaacScript";
|
|
20
|
+
// `isaacscript`
|
|
21
|
+
const REPO_ROOT = path_1.default.join(__dirname, "..");
|
|
22
|
+
// `isaacscript/isaacscript-watcher`
|
|
23
|
+
exports.DISABLE_IT_FILE = "disable.it";
|
|
24
|
+
exports.WATCHER_MOD_NAME = "isaacscript-watcher";
|
|
25
|
+
exports.WATCHER_MOD_SOURCE_PATH = path_1.default.join(REPO_ROOT, exports.WATCHER_MOD_NAME);
|
|
26
|
+
// `isaacscript/file-templates`
|
|
27
|
+
const TEMPLATES_DIR = path_1.default.join(REPO_ROOT, "file-templates");
|
|
28
|
+
// `isaacscript/file-templates/static`
|
|
29
|
+
exports.TEMPLATES_STATIC_DIR = path_1.default.join(TEMPLATES_DIR, "static");
|
|
30
|
+
// `isaacscript/file-templates/dynamic`
|
|
31
|
+
const TEMPLATES_DYNAMIC_DIR = path_1.default.join(TEMPLATES_DIR, "dynamic");
|
|
32
|
+
exports.GITIGNORE = "gitignore"; // Not named ".gitignore" to prevent NPM from deleting it
|
|
33
|
+
exports.GITIGNORE_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.GITIGNORE);
|
|
34
|
+
exports.MAIN_TS = "main.ts";
|
|
35
|
+
exports.MAIN_TS_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.MAIN_TS);
|
|
36
|
+
exports.METADATA_XML = "metadata.xml";
|
|
37
|
+
exports.METADATA_XML_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.METADATA_XML);
|
|
38
|
+
exports.METADATA_VDF = "metadata.vdf";
|
|
39
|
+
exports.METADATA_VDF_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.METADATA_VDF);
|
|
40
|
+
exports.PACKAGE_JSON = "package.json";
|
|
41
|
+
exports.PACKAGE_JSON_TEMPLATE_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.PACKAGE_JSON);
|
|
42
|
+
exports.README_MD = "README.md";
|
|
43
|
+
exports.README_MD_TEMPLATES_PATH = path_1.default.join(TEMPLATES_DYNAMIC_DIR, exports.README_MD);
|
|
44
|
+
// `project`
|
|
45
|
+
exports.CONFIG_FILE_NAME = "isaacscript.json";
|
|
46
|
+
exports.CONFIG_FILE_PATH = path_1.default.join(exports.CWD, exports.CONFIG_FILE_NAME);
|
|
47
|
+
exports.TSCONFIG_PATH = path_1.default.join(exports.CWD, "tsconfig.json");
|
|
48
|
+
exports.PACKAGE_JSON_PATH = path_1.default.join(exports.CWD, "package.json");
|
|
49
|
+
exports.CONSTANTS_TS_PATH = path_1.default.join(exports.CWD, "src", "constants.ts");
|
|
50
|
+
exports.YARN_LOCK_PATH = path_1.default.join(exports.CWD, "yarn.lock");
|
|
51
|
+
// `project/mod`
|
|
52
|
+
exports.MOD_SOURCE_PATH = path_1.default.join(exports.CWD, "mod");
|
|
53
|
+
exports.MAIN_LUA = "main.lua";
|
|
54
|
+
exports.METADATA_XML_PATH = path_1.default.join(exports.MOD_SOURCE_PATH, "metadata.xml");
|
|
55
|
+
exports.VERSION_TXT_PATH = path_1.default.join(exports.MOD_SOURCE_PATH, "version.txt");
|
|
56
|
+
// `project/scripts`
|
|
57
|
+
const SCRIPTS_PATH = path_1.default.join(exports.CWD, "scripts");
|
|
58
|
+
exports.PUBLISH_PRE_COPY_PY_PATH = path_1.default.join(SCRIPTS_PATH, "publish_pre_copy.py");
|
|
59
|
+
exports.PUBLISH_POST_COPY_PY_PATH = path_1.default.join(SCRIPTS_PATH, "publish_post_copy.py");
|
|
60
60
|
//# sourceMappingURL=constants.js.map
|
package/src/exec.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execShell = exports.execPowershell = exports.execExe = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
const constants_1 = require("./constants");
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
function execExe(path, verbose, cwd = constants_1.CWD) {
|
|
10
|
-
if (verbose) {
|
|
11
|
-
console.log(`Executing binary: ${path}`);
|
|
12
|
-
}
|
|
13
|
-
let stdout;
|
|
14
|
-
try {
|
|
15
|
-
const buffer = (0, child_process_1.execSync)(`"${path}"`, {
|
|
16
|
-
cwd,
|
|
17
|
-
});
|
|
18
|
-
stdout = buffer.toString().trim();
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
(0, utils_1.error)(`Failed to run "${chalk_1.default.green(path)}":`, err);
|
|
22
|
-
}
|
|
23
|
-
if (verbose) {
|
|
24
|
-
console.log(`Executed binary: ${path}`);
|
|
25
|
-
}
|
|
26
|
-
return stdout;
|
|
27
|
-
}
|
|
28
|
-
exports.execExe = execExe;
|
|
29
|
-
function execPowershell(command, verbose = false, cwd = constants_1.CWD) {
|
|
30
|
-
if (verbose) {
|
|
31
|
-
console.log(`Executing PowerShell command: ${command}`);
|
|
32
|
-
}
|
|
33
|
-
let stdout;
|
|
34
|
-
try {
|
|
35
|
-
const buffer = (0, child_process_1.execSync)(command, {
|
|
36
|
-
shell: "powershell.exe",
|
|
37
|
-
cwd,
|
|
38
|
-
});
|
|
39
|
-
stdout = buffer.toString().trim();
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
(0, utils_1.error)(`Failed to run PowerShell command "${chalk_1.default.green(command)}":`, err);
|
|
43
|
-
}
|
|
44
|
-
if (verbose) {
|
|
45
|
-
console.log(`Executed PowerShell command: ${command}`);
|
|
46
|
-
}
|
|
47
|
-
return stdout;
|
|
48
|
-
}
|
|
49
|
-
exports.execPowershell = execPowershell;
|
|
50
|
-
/** Returns a tuple of exit status and stdout. The stdout is trimmed for convenience. */
|
|
51
|
-
function execShell(command, args = [], verbose = false, allowFailure = false, cwd = constants_1.CWD) {
|
|
52
|
-
// On Windows, "spawnSync()" will not account for spaces in arguments. Thus, wrap everything in a
|
|
53
|
-
// double quote. This will cause arguments that naturally have double quotes to fail.
|
|
54
|
-
if (command.includes('"')) {
|
|
55
|
-
(0, utils_1.error)("execShell cannot execute commands with double quotes in the command.");
|
|
56
|
-
}
|
|
57
|
-
const argsHasDoubleQuotes = args.some((arg) => arg.includes('"'));
|
|
58
|
-
if (argsHasDoubleQuotes) {
|
|
59
|
-
(0, utils_1.error)("execShell cannot execute commands with double quotes in the arguments.");
|
|
60
|
-
}
|
|
61
|
-
const quotedArgs = args.map((arg) => `"${arg}"`);
|
|
62
|
-
const commandDescription = `${command} ${quotedArgs.join(" ")}`.trim();
|
|
63
|
-
if (verbose) {
|
|
64
|
-
console.log(`Executing command: ${commandDescription}`);
|
|
65
|
-
}
|
|
66
|
-
let spawnSyncReturns;
|
|
67
|
-
try {
|
|
68
|
-
spawnSyncReturns = (0, child_process_1.spawnSync)(command, args, {
|
|
69
|
-
shell: true,
|
|
70
|
-
cwd,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
(0, utils_1.error)(`Failed to run the "${chalk_1.default.green(commandDescription)}" command:`, err);
|
|
75
|
-
}
|
|
76
|
-
if (verbose) {
|
|
77
|
-
console.log(`Executed command: ${commandDescription}`);
|
|
78
|
-
}
|
|
79
|
-
const exitStatus = spawnSyncReturns.status;
|
|
80
|
-
if (exitStatus === null) {
|
|
81
|
-
(0, utils_1.error)(`Failed to get the return status of command: ${commandDescription}`);
|
|
82
|
-
}
|
|
83
|
-
const stdout = spawnSyncReturns.output.join("\n").trim();
|
|
84
|
-
if (exitStatus !== 0) {
|
|
85
|
-
if (allowFailure) {
|
|
86
|
-
return [exitStatus, stdout];
|
|
87
|
-
}
|
|
88
|
-
console.error(`Failed to run the "${chalk_1.default.green(commandDescription)}" command with an exit code of ${exitStatus}.`);
|
|
89
|
-
console.error("The output was as follows:");
|
|
90
|
-
console.error(stdout);
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
return [exitStatus, stdout];
|
|
94
|
-
}
|
|
95
|
-
exports.execShell = execShell;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execShell = exports.execPowershell = exports.execExe = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
function execExe(path, verbose, cwd = constants_1.CWD) {
|
|
10
|
+
if (verbose) {
|
|
11
|
+
console.log(`Executing binary: ${path}`);
|
|
12
|
+
}
|
|
13
|
+
let stdout;
|
|
14
|
+
try {
|
|
15
|
+
const buffer = (0, child_process_1.execSync)(`"${path}"`, {
|
|
16
|
+
cwd,
|
|
17
|
+
});
|
|
18
|
+
stdout = buffer.toString().trim();
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
(0, utils_1.error)(`Failed to run "${chalk_1.default.green(path)}":`, err);
|
|
22
|
+
}
|
|
23
|
+
if (verbose) {
|
|
24
|
+
console.log(`Executed binary: ${path}`);
|
|
25
|
+
}
|
|
26
|
+
return stdout;
|
|
27
|
+
}
|
|
28
|
+
exports.execExe = execExe;
|
|
29
|
+
function execPowershell(command, verbose = false, cwd = constants_1.CWD) {
|
|
30
|
+
if (verbose) {
|
|
31
|
+
console.log(`Executing PowerShell command: ${command}`);
|
|
32
|
+
}
|
|
33
|
+
let stdout;
|
|
34
|
+
try {
|
|
35
|
+
const buffer = (0, child_process_1.execSync)(command, {
|
|
36
|
+
shell: "powershell.exe",
|
|
37
|
+
cwd,
|
|
38
|
+
});
|
|
39
|
+
stdout = buffer.toString().trim();
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
(0, utils_1.error)(`Failed to run PowerShell command "${chalk_1.default.green(command)}":`, err);
|
|
43
|
+
}
|
|
44
|
+
if (verbose) {
|
|
45
|
+
console.log(`Executed PowerShell command: ${command}`);
|
|
46
|
+
}
|
|
47
|
+
return stdout;
|
|
48
|
+
}
|
|
49
|
+
exports.execPowershell = execPowershell;
|
|
50
|
+
/** Returns a tuple of exit status and stdout. The stdout is trimmed for convenience. */
|
|
51
|
+
function execShell(command, args = [], verbose = false, allowFailure = false, cwd = constants_1.CWD) {
|
|
52
|
+
// On Windows, "spawnSync()" will not account for spaces in arguments. Thus, wrap everything in a
|
|
53
|
+
// double quote. This will cause arguments that naturally have double quotes to fail.
|
|
54
|
+
if (command.includes('"')) {
|
|
55
|
+
(0, utils_1.error)("execShell cannot execute commands with double quotes in the command.");
|
|
56
|
+
}
|
|
57
|
+
const argsHasDoubleQuotes = args.some((arg) => arg.includes('"'));
|
|
58
|
+
if (argsHasDoubleQuotes) {
|
|
59
|
+
(0, utils_1.error)("execShell cannot execute commands with double quotes in the arguments.");
|
|
60
|
+
}
|
|
61
|
+
const quotedArgs = args.map((arg) => `"${arg}"`);
|
|
62
|
+
const commandDescription = `${command} ${quotedArgs.join(" ")}`.trim();
|
|
63
|
+
if (verbose) {
|
|
64
|
+
console.log(`Executing command: ${commandDescription}`);
|
|
65
|
+
}
|
|
66
|
+
let spawnSyncReturns;
|
|
67
|
+
try {
|
|
68
|
+
spawnSyncReturns = (0, child_process_1.spawnSync)(command, args, {
|
|
69
|
+
shell: true,
|
|
70
|
+
cwd,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
(0, utils_1.error)(`Failed to run the "${chalk_1.default.green(commandDescription)}" command:`, err);
|
|
75
|
+
}
|
|
76
|
+
if (verbose) {
|
|
77
|
+
console.log(`Executed command: ${commandDescription}`);
|
|
78
|
+
}
|
|
79
|
+
const exitStatus = spawnSyncReturns.status;
|
|
80
|
+
if (exitStatus === null) {
|
|
81
|
+
(0, utils_1.error)(`Failed to get the return status of command: ${commandDescription}`);
|
|
82
|
+
}
|
|
83
|
+
const stdout = spawnSyncReturns.output.join("\n").trim();
|
|
84
|
+
if (exitStatus !== 0) {
|
|
85
|
+
if (allowFailure) {
|
|
86
|
+
return [exitStatus, stdout];
|
|
87
|
+
}
|
|
88
|
+
console.error(`Failed to run the "${chalk_1.default.green(commandDescription)}" command with an exit code of ${exitStatus}.`);
|
|
89
|
+
console.error("The output was as follows:");
|
|
90
|
+
console.error(stdout);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
return [exitStatus, stdout];
|
|
94
|
+
}
|
|
95
|
+
exports.execShell = execShell;
|
|
96
96
|
//# sourceMappingURL=exec.js.map
|