isaacscript 1.1.53 → 1.1.57
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/.cspell.json +1 -3
- package/.eslintrc.js +1 -15
- package/.vscode/extensions.json +1 -0
- package/.vscode/settings.json +4 -0
- package/dist/package.json +8 -6
- package/dist/src/checkForWindowsTerminalBugs.js +20 -52
- package/dist/src/checkForWindowsTerminalBugs.js.map +1 -1
- package/dist/src/commands/init/checkIfProjectPathExists.js +3 -7
- package/dist/src/commands/init/checkIfProjectPathExists.js.map +1 -1
- package/dist/src/commands/init/checkModTargetDirectory.js +3 -8
- package/dist/src/commands/init/checkModTargetDirectory.js.map +1 -1
- package/dist/src/commands/init/createMod.js +85 -11
- package/dist/src/commands/init/createMod.js.map +1 -1
- package/dist/src/commands/init/getModsDir.js +6 -13
- package/dist/src/commands/init/getModsDir.js.map +1 -1
- package/dist/src/commands/init/getProjectPath.js +4 -17
- package/dist/src/commands/init/getProjectPath.js.map +1 -1
- package/dist/src/commands/init/init.js +18 -15
- package/dist/src/commands/init/init.js.map +1 -1
- package/dist/src/commands/init/promptSaveSlot.js +4 -14
- package/dist/src/commands/init/promptSaveSlot.js.map +1 -1
- package/dist/src/commands/init/promptVSCode.js +3 -8
- package/dist/src/commands/init/promptVSCode.js.map +1 -1
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +0 -1
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +1 -1
- package/dist/src/commands/monitor/monitor.js +10 -4
- package/dist/src/commands/monitor/monitor.js.map +1 -1
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +0 -1
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
- package/dist/src/commands/publish/publish.js +8 -10
- package/dist/src/commands/publish/publish.js.map +1 -1
- package/dist/src/constants.js +5 -1
- package/dist/src/constants.js.map +1 -1
- package/dist/src/main.js +2 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/parseArgs.js +62 -58
- package/dist/src/parseArgs.js.map +1 -1
- package/dist/src/plugins/addCrashDebugStatements.js +31 -0
- package/dist/src/plugins/addCrashDebugStatements.js.map +1 -0
- package/dist/src/prompt.js +90 -0
- package/dist/src/prompt.js.map +1 -0
- package/dist/src/types/GitHubCLIHostsYAML.js +3 -0
- package/dist/src/types/GitHubCLIHostsYAML.js.map +1 -0
- package/dist/src/util.js +12 -23
- package/dist/src/util.js.map +1 -1
- package/file-templates/dynamic/README.md +2 -2
- package/file-templates/dynamic/main.ts +4 -2
- package/file-templates/dynamic/metadata.xml +3 -3
- package/file-templates/dynamic/package.json +1 -1
- package/file-templates/static/.vscode/extensions.json +1 -0
- package/file-templates/static/.vscode/settings.json +4 -0
- package/file-templates/static/lint.sh +10 -9
- package/lint.sh +6 -10
- package/package.json +8 -6
- package/src/checkForWindowsTerminalBugs.ts +35 -73
- package/src/commands/init/checkIfProjectPathExists.ts +4 -7
- package/src/commands/init/checkModTargetDirectory.ts +7 -9
- package/src/commands/init/createMod.ts +132 -13
- package/src/commands/init/getModsDir.ts +8 -14
- package/src/commands/init/getProjectPath.ts +7 -19
- package/src/commands/init/init.ts +25 -13
- package/src/commands/init/promptSaveSlot.ts +6 -13
- package/src/commands/init/promptVSCode.ts +5 -9
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +0 -2
- package/src/commands/monitor/monitor.ts +13 -4
- package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +0 -2
- package/src/commands/publish/publish.ts +11 -10
- package/src/constants.ts +5 -0
- package/src/main.ts +2 -0
- package/src/parseArgs.ts +34 -28
- package/src/plugins/addCrashDebugStatements.ts +29 -0
- package/src/prompt.ts +110 -0
- package/src/types/GitHubCLIHostsYAML.ts +7 -0
- package/src/util.ts +12 -23
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Both the Inquirer.js library and the Prompts library have a bug where text is duplicated in a Git
|
|
3
|
+
// Bash terminal
|
|
4
|
+
// Thus, we revert to using the simpler Prompt library
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getInputInt = exports.getInputString = exports.getInputYesNo = exports.promptInit = void 0;
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const prompt_1 = __importDefault(require("prompt"));
|
|
12
|
+
const util_1 = require("./util");
|
|
13
|
+
const VALID_YES_RESPONSES = new Set(["yes", "ye", "y"]);
|
|
14
|
+
const VALID_NO_RESPONSES = new Set(["no", "n"]);
|
|
15
|
+
function promptInit() {
|
|
16
|
+
// Override some of the prompt library's default values
|
|
17
|
+
// https://github.com/flatiron/prompt#customizing-your-prompt
|
|
18
|
+
prompt_1.default.message = chalk_1.default.green("?");
|
|
19
|
+
prompt_1.default.delimiter = " ";
|
|
20
|
+
prompt_1.default.colors = false;
|
|
21
|
+
}
|
|
22
|
+
exports.promptInit = promptInit;
|
|
23
|
+
async function getInputYesNo(msg, defaultValue = true) {
|
|
24
|
+
prompt_1.default.start();
|
|
25
|
+
// Capitalize the letter that represents the default option
|
|
26
|
+
const y = defaultValue ? "Y" : "y";
|
|
27
|
+
const n = defaultValue ? "n" : "N";
|
|
28
|
+
const questionSuffix = `(${y}\\${n})`;
|
|
29
|
+
const description = `${chalk_1.default.bold(msg)} ${chalk_1.default.gray(questionSuffix)}`;
|
|
30
|
+
const { response } = await prompt_1.default.get({
|
|
31
|
+
properties: {
|
|
32
|
+
response: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (typeof response !== "string") {
|
|
39
|
+
console.log(typeof response);
|
|
40
|
+
(0, util_1.error)("Failed to get a proper response from the prompt library.");
|
|
41
|
+
}
|
|
42
|
+
const cleanedResponse = response.toLowerCase().trim();
|
|
43
|
+
// Default to true
|
|
44
|
+
if (cleanedResponse === "") {
|
|
45
|
+
return defaultValue;
|
|
46
|
+
}
|
|
47
|
+
if (VALID_YES_RESPONSES.has(cleanedResponse)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (VALID_NO_RESPONSES.has(cleanedResponse)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
(0, util_1.error)('Invalid response; must answer "yes" or "no".');
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
exports.getInputYesNo = getInputYesNo;
|
|
57
|
+
async function getInputString(msg, defaultValue) {
|
|
58
|
+
prompt_1.default.start();
|
|
59
|
+
let description = `${chalk_1.default.bold(msg)}`;
|
|
60
|
+
if (defaultValue !== undefined) {
|
|
61
|
+
description += ` ${chalk_1.default.gray(`(${defaultValue})`)}`;
|
|
62
|
+
}
|
|
63
|
+
const { response } = await prompt_1.default.get({
|
|
64
|
+
properties: {
|
|
65
|
+
response: {
|
|
66
|
+
type: "string",
|
|
67
|
+
description,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
if (typeof response !== "string") {
|
|
72
|
+
(0, util_1.error)("Failed to get a proper response from the prompt library.");
|
|
73
|
+
}
|
|
74
|
+
if (response === "" && defaultValue !== undefined) {
|
|
75
|
+
return defaultValue;
|
|
76
|
+
}
|
|
77
|
+
return response.trim();
|
|
78
|
+
}
|
|
79
|
+
exports.getInputString = getInputString;
|
|
80
|
+
async function getInputInt(msg, defaultValue = 1) {
|
|
81
|
+
const defaultValueString = defaultValue.toString();
|
|
82
|
+
const string = await getInputString(msg, defaultValueString);
|
|
83
|
+
const int = (0, util_1.parseIntSafe)(string);
|
|
84
|
+
if (Number.isNaN(int)) {
|
|
85
|
+
(0, util_1.error)("Error: You must enter an integer.");
|
|
86
|
+
}
|
|
87
|
+
return int;
|
|
88
|
+
}
|
|
89
|
+
exports.getInputInt = getInputInt;
|
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AAE;QACjD,OAAO,YAAY,CAAC;KACrB;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AA7BD,wCA6BC;AAEM,KAAK,UAAU,WAAW,CAC/B,GAAW,EACX,YAAY,GAAG,CAAC;IAEhB,MAAM,kBAAkB,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,IAAA,mBAAY,EAAC,MAAM,CAAC,CAAC;IAEjC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACrB,IAAA,YAAK,EAAC,mCAAmC,CAAC,CAAC;KAC5C;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAbD,kCAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubCLIHostsYAML.js","sourceRoot":"","sources":["../../../src/types/GitHubCLIHostsYAML.ts"],"names":[],"mappings":""}
|
package/dist/src/util.js
CHANGED
|
@@ -3,13 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.snakeKebabToCamel = exports.parseIntSafe = exports.hasWhiteSpace = exports.getTime = exports.getModTargetDirectoryName = exports.execShell = exports.
|
|
6
|
+
exports.snakeKebabToCamel = exports.parseIntSafe = exports.hasWhiteSpace = exports.getTime = exports.getModTargetDirectoryName = exports.execShell = exports.error = exports.ensureAllCases = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const moment_1 = __importDefault(require("moment"));
|
|
10
10
|
const constants_1 = require("./constants");
|
|
11
|
-
// Use this on a switch statement's default case to get
|
|
12
|
-
// the linter to complain if a case was not predicted
|
|
13
11
|
const ensureAllCases = (obj) => obj;
|
|
14
12
|
exports.ensureAllCases = ensureAllCases;
|
|
15
13
|
function error(...args) {
|
|
@@ -17,21 +15,8 @@ function error(...args) {
|
|
|
17
15
|
process.exit(1);
|
|
18
16
|
}
|
|
19
17
|
exports.error = error;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const buffer = (0, child_process_1.execSync)(`"${path}"`, {
|
|
24
|
-
cwd,
|
|
25
|
-
});
|
|
26
|
-
stdout = buffer.toString().trim();
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
error(`Failed to run "${chalk_1.default.green(path)}":`, err);
|
|
30
|
-
}
|
|
31
|
-
return stdout;
|
|
32
|
-
}
|
|
33
|
-
exports.execExe = execExe;
|
|
34
|
-
function execShell(command, args, allowFailure = false, cwd = constants_1.CWD) {
|
|
18
|
+
/** Returns an array of exit status and stdout. */
|
|
19
|
+
function execShell(command, args = [], allowFailure = false, cwd = constants_1.CWD) {
|
|
35
20
|
// On Windows, "spawnSync()" will not account for spaces in arguments
|
|
36
21
|
// Thus, wrap everything in a double quote
|
|
37
22
|
// This will cause arguments that naturally have double quotes to fail
|
|
@@ -81,9 +66,10 @@ function hasWhiteSpace(s) {
|
|
|
81
66
|
return /\s/g.test(s);
|
|
82
67
|
}
|
|
83
68
|
exports.hasWhiteSpace = hasWhiteSpace;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
/**
|
|
70
|
+
* parseIntSafe is a more reliable version of parseInt. By default, "parseInt('1a')" will return
|
|
71
|
+
* "1", which is unexpected. This returns either an integer or NaN.
|
|
72
|
+
*/
|
|
87
73
|
function parseIntSafe(input) {
|
|
88
74
|
if (typeof input !== "string") {
|
|
89
75
|
return NaN;
|
|
@@ -106,8 +92,11 @@ function parseIntSafe(input) {
|
|
|
106
92
|
return parseInt(trimmedInput, 10);
|
|
107
93
|
}
|
|
108
94
|
exports.parseIntSafe = parseIntSafe;
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Converts snake_case and kebab-case to camelCase.
|
|
97
|
+
*
|
|
98
|
+
* From: https://hisk.io/javascript-snake-to-camel/
|
|
99
|
+
*/
|
|
111
100
|
function snakeKebabToCamel(str) {
|
|
112
101
|
return str.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace("-", "").replace("_", ""));
|
|
113
102
|
}
|
package/dist/src/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iDAA4D;AAC5D,oDAA4B;AAC5B,2CAA0D;AAGnD,MAAM,cAAc,GAAG,CAAC,GAAU,EAAS,EAAE,CAAC,GAAG,CAAC;AAA5C,QAAA,cAAc,kBAA8B;AAEzD,SAAgB,KAAK,CAAC,GAAG,IAAe;IACtC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAHD,sBAGC;AAED,kDAAkD;AAClD,SAAgB,SAAS,CACvB,OAAe,EACf,OAAiB,EAAE,EACnB,YAAY,GAAG,KAAK,EACpB,GAAG,GAAG,eAAG;IAET,qEAAqE;IACrE,0CAA0C;IAC1C,sEAAsE;IACtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAC;SACH;QAED,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CA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3
|
-
|
|
3
|
+
MOD_NAME_TO_REPLACE is a mod for *[The Binding of Isaac: Repentance](https://store.steampowered.com/app/1426300/The_Binding_of_Isaac_Repentance/)*, written in [TypeScript](https://www.typescriptlang.org/) using the [IsaacScript](https://isaacscript.github.io/) framework.
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
const MOD_NAME = "MOD_NAME_TO_REPLACE";
|
|
2
|
+
|
|
1
3
|
export function main(): void {
|
|
2
4
|
// Instantiate a new mod object, which grants the ability to add callback functions that
|
|
3
5
|
// correspond to in-game events
|
|
4
|
-
const mod = RegisterMod(
|
|
6
|
+
const mod = RegisterMod(MOD_NAME, 1);
|
|
5
7
|
|
|
6
8
|
// Set a callback function that corresponds to when a new run is started
|
|
7
9
|
mod.AddCallback(ModCallbacks.MC_POST_GAME_STARTED, postGameStarted);
|
|
8
10
|
|
|
9
11
|
// Print an initialization message to the "log.txt" file
|
|
10
|
-
Isaac.DebugString(
|
|
12
|
+
Isaac.DebugString(`${MOD_NAME} initialized.`);
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
function postGameStarted() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<metadata>
|
|
3
|
-
<name>
|
|
4
|
-
<directory>
|
|
5
|
-
<description>
|
|
3
|
+
<name>MOD_NAME_TO_REPLACE</name>
|
|
4
|
+
<directory>MOD_NAME_TO_REPLACE</directory>
|
|
5
|
+
<description>MOD_NAME_TO_REPLACE is a currently a work in progress.</description>
|
|
6
6
|
<version>1.0</version>
|
|
7
7
|
<visibility/>
|
|
8
8
|
</metadata>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// https://go.microsoft.com/fwlink/?LinkId=827846
|
|
4
4
|
{
|
|
5
5
|
"recommendations": [
|
|
6
|
+
"esbenp.prettier-vscode", // The TypeScript formatter
|
|
6
7
|
"dbaeumer.vscode-eslint", // The TypeScript linter
|
|
7
8
|
"streetsidesoftware.code-spell-checker", // A spell-checker extension based on cspell
|
|
8
9
|
"typescript-to-lua.vscode-typescript-to-lua", // The TypeScriptToLua extension
|
|
@@ -35,12 +35,16 @@
|
|
|
35
35
|
|
|
36
36
|
// Automatically run the formatter when a JavaScript or TypeScript file is saved
|
|
37
37
|
"[javascript]": {
|
|
38
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
39
|
+
"editor.formatOnSave": true,
|
|
38
40
|
"editor.codeActionsOnSave": [
|
|
39
41
|
"source.fixAll.eslint",
|
|
40
42
|
],
|
|
41
43
|
"editor.tabSize": 2,
|
|
42
44
|
},
|
|
43
45
|
"[typescript]": {
|
|
46
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
47
|
+
"editor.formatOnSave": true,
|
|
44
48
|
"editor.codeActionsOnSave": [
|
|
45
49
|
"source.fixAll.eslint",
|
|
46
50
|
],
|
|
@@ -6,25 +6,26 @@ set -e # Exit on any errors
|
|
|
6
6
|
# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
|
|
7
7
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
8
8
|
|
|
9
|
-
# The latest version of some ESLint plugins require Node.js v16
|
|
10
|
-
NODE_VERSION=$(node --version | cut -c 2-3)
|
|
11
|
-
if (($NODE_VERSION < 16)); then
|
|
12
|
-
echo "error: requires Node.js version 16"
|
|
13
|
-
exit 1
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
9
|
SECONDS=0
|
|
17
10
|
|
|
18
11
|
cd "$DIR"
|
|
19
12
|
|
|
20
|
-
# Step 1 - Use
|
|
13
|
+
# Step 1 - Use Prettier to check formatting
|
|
14
|
+
npx prettier --check "src/**/*.ts"
|
|
15
|
+
|
|
16
|
+
# Step 2 - Use ESLint to lint the TypeScript
|
|
21
17
|
# Since all ESLint errors are set to warnings,
|
|
22
18
|
# we set max warnings to 0 so that warnings will fail in CI
|
|
23
19
|
npx eslint --max-warnings 0 src
|
|
24
20
|
|
|
25
|
-
# Step
|
|
21
|
+
# Step 3 - Spell check every file using cspell
|
|
26
22
|
# We use no-progress and no-summary because we want to only output errors
|
|
27
23
|
npx cspell --no-progress --no-summary "src/**/*.ts"
|
|
28
24
|
npx cspell --no-progress --no-summary "mod/metadata.xml"
|
|
29
25
|
|
|
26
|
+
# Step 4 - Check for unused imports
|
|
27
|
+
# The "--error" flag makes it return an error code of 1 if unused exports are found
|
|
28
|
+
# (this starts out disabled by default, but you can uncomment it to find dead code)
|
|
29
|
+
# npx ts-prune -error
|
|
30
|
+
|
|
30
31
|
echo "Successfully linted in $SECONDS seconds."
|
package/lint.sh
CHANGED
|
@@ -6,27 +6,23 @@ set -e # Exit on any errors
|
|
|
6
6
|
# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
|
|
7
7
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
8
8
|
|
|
9
|
-
# The latest version of some ESLint plugins require Node.js v16
|
|
10
|
-
NODE_VERSION=$(node --version | cut -c 2-3)
|
|
11
|
-
if (($NODE_VERSION < 16)); then
|
|
12
|
-
echo "error: requires Node.js version 16"
|
|
13
|
-
exit 1
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
9
|
SECONDS=0
|
|
17
10
|
|
|
18
11
|
cd "$DIR"
|
|
19
12
|
|
|
20
|
-
# Step 1 - Use
|
|
13
|
+
# Step 1 - Use Prettier to check formatting
|
|
14
|
+
npx prettier --check "src/**/*.ts"
|
|
15
|
+
|
|
16
|
+
# Step 2 - Use ESLint to lint the TypeScript
|
|
21
17
|
# Since all ESLint errors are set to warnings,
|
|
22
18
|
# we set max warnings to 0 so that warnings will fail in CI
|
|
23
19
|
npx eslint --max-warnings 0 src
|
|
24
20
|
|
|
25
|
-
# Step
|
|
21
|
+
# Step 3 - Spell check every file using cspell
|
|
26
22
|
# We use no-progress and no-summary because we want to only output errors
|
|
27
23
|
npx cspell --no-progress --no-summary "src/**/*.ts"
|
|
28
24
|
|
|
29
|
-
# Step
|
|
25
|
+
# Step 4 - Check for unused imports
|
|
30
26
|
# The "--error" flag makes it return an error code of 1 if unused exports are found
|
|
31
27
|
npx ts-prune --error
|
|
32
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.57",
|
|
4
4
|
"description": "A command line tool for managing Isaac mods written in TypeScript",
|
|
5
5
|
"homepage": "https://isaacscript.github.io/",
|
|
6
6
|
"bugs": {
|
|
@@ -23,24 +23,26 @@
|
|
|
23
23
|
"fs-extra": "^10.0.0",
|
|
24
24
|
"jsonc-parser": "^3.0.0",
|
|
25
25
|
"moment": "^2.29.1",
|
|
26
|
-
"npm-check-updates": "^12.0.
|
|
27
|
-
"
|
|
26
|
+
"npm-check-updates": "^12.0.3",
|
|
27
|
+
"prompt": "^1.2.0",
|
|
28
|
+
"source-map": "^0.7.3",
|
|
28
29
|
"source-map-support": "^0.5.21",
|
|
29
30
|
"sync-directory": "^4.0.7",
|
|
30
31
|
"typescript": "4.4.4",
|
|
31
32
|
"typescript-to-lua": "1.1.1",
|
|
32
33
|
"update-notifier": "^5.1.0",
|
|
34
|
+
"yaml": "^1.10.2",
|
|
33
35
|
"yargs": "^17.3.0"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@types/command-exists": "^1.2.0",
|
|
37
39
|
"@types/figlet": "^1.5.4",
|
|
38
40
|
"@types/fs-extra": "^9.0.13",
|
|
39
|
-
"@types/node": "^16.11.
|
|
40
|
-
"@types/
|
|
41
|
+
"@types/node": "^16.11.12",
|
|
42
|
+
"@types/prompt": "^1.1.2",
|
|
41
43
|
"@types/source-map-support": "^0.5.4",
|
|
42
44
|
"@types/update-notifier": "^5.1.0",
|
|
43
45
|
"@types/yargs": "^17.0.7",
|
|
44
|
-
"isaacscript-lint": "^1.0.
|
|
46
|
+
"isaacscript-lint": "^1.0.74"
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import os from "os";
|
|
4
3
|
import path from "path";
|
|
5
|
-
import
|
|
4
|
+
import { HOME_DIR } from "./constants";
|
|
6
5
|
import * as file from "./file";
|
|
7
|
-
import {
|
|
6
|
+
import { getInputYesNo } from "./prompt";
|
|
7
|
+
import { error } from "./util";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
const homeDir = os.homedir();
|
|
11
|
-
|
|
12
|
-
const BASH_PROFILE_PATH = path.join(homeDir, ".bash_profile");
|
|
13
|
-
const WINDOWS_CODE_PAGE = "65001";
|
|
9
|
+
const BASH_PROFILE_PATH = path.join(HOME_DIR, ".bash_profile");
|
|
14
10
|
|
|
15
11
|
// By default, Git Bash for Windows uses MINGW64
|
|
16
|
-
// This will not work correctly with the
|
|
12
|
+
// This will not work correctly with the inquirer library (or any other NodeJS input library)
|
|
17
13
|
// Try to detect this and warn the end-user
|
|
18
14
|
export async function checkForWindowsTerminalBugs(): Promise<void> {
|
|
19
15
|
if (process.platform !== "win32") {
|
|
@@ -24,46 +20,9 @@ export async function checkForWindowsTerminalBugs(): Promise<void> {
|
|
|
24
20
|
return;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
await checkForCodePage();
|
|
28
23
|
await checkForWindowsBugColor();
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
async function checkForCodePage() {
|
|
32
|
-
const chcpPath = "C:\\Windows\\System32\\chcp.com";
|
|
33
|
-
const stdout = execExe(chcpPath).trim();
|
|
34
|
-
// The output of "chcp" will be different depending on the language of the Windows installation,
|
|
35
|
-
// so we only parse the final number
|
|
36
|
-
const match = /(\d+)$/.exec(stdout);
|
|
37
|
-
if (match === null) {
|
|
38
|
-
error(`Failed to parse the results of "${chalk.green(chcpPath)}":`, stdout);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const activeCodePage = match[1].trim();
|
|
42
|
-
if (activeCodePage === WINDOWS_CODE_PAGE) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
console.error(
|
|
47
|
-
chalk.red(
|
|
48
|
-
`Error: It looks like you are using Git Bash for Windows (MINGW64) with an incorrect code page of "${chalk.green(
|
|
49
|
-
activeCodePage,
|
|
50
|
-
)}". (It should be equal to "${WINDOWS_CODE_PAGE}".)`,
|
|
51
|
-
),
|
|
52
|
-
);
|
|
53
|
-
const response = await prompts({
|
|
54
|
-
type: "confirm",
|
|
55
|
-
name: "fixCodePage",
|
|
56
|
-
message:
|
|
57
|
-
'Do you want me to fix this for you? (Type "y", then press "enter".)',
|
|
58
|
-
initial: true,
|
|
59
|
-
});
|
|
60
|
-
if (response.fixCodePage === false) {
|
|
61
|
-
error("Ok then. Good-bye.");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
applyFixesToBashProfile();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
26
|
async function checkForWindowsBugColor() {
|
|
68
27
|
if (process.env.FORCE_COLOR === "true") {
|
|
69
28
|
return;
|
|
@@ -80,15 +39,11 @@ async function checkForWindowsBugColor() {
|
|
|
80
39
|
"This is necessary in order for colors to work properly in the terminal.",
|
|
81
40
|
);
|
|
82
41
|
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
initial: true,
|
|
89
|
-
});
|
|
90
|
-
if (response.fixColors === false) {
|
|
91
|
-
error("Ok then. Good-bye.");
|
|
42
|
+
const shouldFixColors = await getInputYesNo(
|
|
43
|
+
"Do you want me to fix this for you?",
|
|
44
|
+
);
|
|
45
|
+
if (!shouldFixColors) {
|
|
46
|
+
return;
|
|
92
47
|
}
|
|
93
48
|
|
|
94
49
|
applyFixesToBashProfile();
|
|
@@ -103,8 +58,29 @@ function applyFixesToBashProfile() {
|
|
|
103
58
|
bashProfileContents = "";
|
|
104
59
|
}
|
|
105
60
|
|
|
106
|
-
|
|
61
|
+
const appendText = getBashProfileAppendText(bashProfileContents);
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
fs.appendFileSync(BASH_PROFILE_PATH, appendText);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
error(`Failed to append text to "${BASH_PROFILE_PATH}":`, err);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log(
|
|
70
|
+
chalk.green("Complete!"),
|
|
71
|
+
`The terminal fixes have been added to: ${chalk.green(BASH_PROFILE_PATH)}`,
|
|
72
|
+
);
|
|
73
|
+
console.log(
|
|
74
|
+
chalk.red(
|
|
75
|
+
"Please close and re-open your terminal, then run this program again.",
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function getBashProfileAppendText(bashProfileContents: string) {
|
|
107
82
|
let newText = "";
|
|
83
|
+
|
|
108
84
|
if (
|
|
109
85
|
bashProfileContents !== "" &&
|
|
110
86
|
bashProfileContents[bashProfileContents.length - 1] !== "\n"
|
|
@@ -113,29 +89,15 @@ function applyFixesToBashProfile() {
|
|
|
113
89
|
// Add an extra newline if this is not the case
|
|
114
90
|
newText += "\n";
|
|
115
91
|
}
|
|
92
|
+
|
|
116
93
|
if (bashProfileContents !== "") {
|
|
117
94
|
// If the Bash profile exists and has data, add an extra newline between the existing stuff and
|
|
118
95
|
// the new lines added by us
|
|
119
96
|
newText += "\n";
|
|
120
97
|
}
|
|
98
|
+
|
|
121
99
|
newText += "# Terminal fixes added by IsaacScript\n";
|
|
122
|
-
newText += `chcp.com ${WINDOWS_CODE_PAGE} > /dev/null\n`;
|
|
123
100
|
newText += "export FORCE_COLOR=true\n";
|
|
124
101
|
|
|
125
|
-
|
|
126
|
-
fs.appendFileSync(BASH_PROFILE_PATH, newText);
|
|
127
|
-
} catch (err) {
|
|
128
|
-
error(`Failed to append text to "${BASH_PROFILE_PATH}":`, err);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
console.log(
|
|
132
|
-
chalk.green("Complete!"),
|
|
133
|
-
`I have added the terminal fixes to "${BASH_PROFILE_PATH}".`,
|
|
134
|
-
);
|
|
135
|
-
console.log(
|
|
136
|
-
chalk.red(
|
|
137
|
-
"Please close and re-open your terminal, then run this program again.",
|
|
138
|
-
),
|
|
139
|
-
);
|
|
140
|
-
process.exit(0);
|
|
102
|
+
return newText;
|
|
141
103
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import prompts from "prompts";
|
|
3
2
|
import { CWD } from "../../constants";
|
|
4
3
|
import * as file from "../../file";
|
|
4
|
+
import { getInputYesNo } from "../../prompt";
|
|
5
5
|
import { error } from "../../util";
|
|
6
6
|
|
|
7
7
|
export async function checkIfProjectPathExists(
|
|
@@ -15,12 +15,9 @@ export async function checkIfProjectPathExists(
|
|
|
15
15
|
)}".`,
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
message: "Do you want me to delete it?",
|
|
22
|
-
});
|
|
23
|
-
if (!response.delete) { // eslint-disable-line
|
|
18
|
+
const shouldDelete = await getInputYesNo("Do you want me to delete it?");
|
|
19
|
+
|
|
20
|
+
if (!shouldDelete) {
|
|
24
21
|
error("Ok then. Good-bye.");
|
|
25
22
|
}
|
|
26
23
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import prompts from "prompts";
|
|
4
3
|
import * as file from "../../file";
|
|
4
|
+
import { getInputYesNo } from "../../prompt";
|
|
5
5
|
import { error } from "../../util";
|
|
6
6
|
|
|
7
7
|
export async function checkModTargetDirectory(
|
|
@@ -21,14 +21,12 @@ export async function checkModTargetDirectory(
|
|
|
21
21
|
console.error(
|
|
22
22
|
"When you run IsaacScript, it will want to create a directory here so that it can sync it with your project folder.",
|
|
23
23
|
);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
if (response.deleteDirectory === false) {
|
|
24
|
+
|
|
25
|
+
const shouldDeleteDirectory = await getInputYesNo(
|
|
26
|
+
"Should I delete the existing directory for you? (Make sure that it does not contain anything important first.)",
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
if (!shouldDeleteDirectory) {
|
|
32
30
|
error("Ok then. You delete it yourself. Good bye.");
|
|
33
31
|
}
|
|
34
32
|
|