isaacscript 1.1.28 → 1.1.32
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 -0
- package/dist/package.json +1 -1
- package/dist/src/commands/init/getModsDir.js +0 -3
- package/dist/src/commands/init/getModsDir.js.map +1 -1
- package/dist/src/commands/init/init.js +13 -5
- package/dist/src/commands/init/init.js.map +1 -1
- package/dist/src/commands/init/installVSCodeExtensions.js +2 -2
- package/dist/src/commands/init/installVSCodeExtensions.js.map +1 -1
- package/dist/src/commands/init/promptVSCode.js +5 -5
- package/dist/src/commands/init/promptVSCode.js.map +1 -1
- package/dist/src/file.js +2 -7
- package/dist/src/file.js.map +1 -1
- package/dist/src/monkeyPatch.js +19 -0
- package/dist/src/monkeyPatch.js.map +1 -1
- package/misc/mouseover.png +0 -0
- package/package.json +1 -1
- package/src/commands/init/getModsDir.ts +0 -5
- package/src/commands/init/init.ts +15 -5
- package/src/commands/init/installVSCodeExtensions.ts +5 -2
- package/src/commands/init/promptVSCode.ts +5 -4
- package/src/file.ts +1 -6
- package/src/monkeyPatch.ts +21 -0
package/.cspell.json
CHANGED
package/dist/package.json
CHANGED
|
@@ -41,9 +41,6 @@ async function getModsDir(argv) {
|
|
|
41
41
|
return argv.modsDirectory;
|
|
42
42
|
}
|
|
43
43
|
const defaultModsPath = getDefaultModsPath(process.platform);
|
|
44
|
-
if (file.exists(defaultModsPath) && file.isSymbolicLink(defaultModsPath)) {
|
|
45
|
-
(0, util_1.error)('Error: Your mods directory appears to be a symbolic link, which is not currently supported. If you want to get around this, try specifying a directory with the "--mods-directory" command line flag, but the rest of the program may not work properly.');
|
|
46
|
-
}
|
|
47
44
|
if (file.exists(defaultModsPath) && file.isDir(defaultModsPath)) {
|
|
48
45
|
return defaultModsPath;
|
|
49
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModsDir.js","sourceRoot":"","sources":["../../../../src/commands/init/getModsDir.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AACxB,sDAA8B;AAC9B,iDAAmC;AACnC,qCAAmC;AAEnC,mGAAmG;AACnG,MAAM,OAAO,GAAG,YAAE,CAAC,OAAO,EAAE,CAAC;AAE7B,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,yBAAyB,GAAG,cAAI,CAAC,IAAI,CACzC,IAAI,EACJ,qBAAqB,EACrB,OAAO,EACP,WAAW,EACX,QAAQ,EACR,8BAA8B,EAC9B,IAAI,CACL,CAAC;AAEF,kCAAkC;AAClC,MAAM,uBAAuB,GAAG,cAAI,CAAC,IAAI,CACvC,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,8BAA8B,EAC9B,IAAI,CACL,CAAC;AAEa,KAAK,UAAU,UAAU,CACtC,IAA6B;IAE7B,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE;QACpC,2DAA2D;QAC3D,gDAAgD;QAChD,OAAO,IAAI,CAAC,aAAuB,CAAC;KACrC;IAED,MAAM,eAAe,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"getModsDir.js","sourceRoot":"","sources":["../../../../src/commands/init/getModsDir.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AACxB,sDAA8B;AAC9B,iDAAmC;AACnC,qCAAmC;AAEnC,mGAAmG;AACnG,MAAM,OAAO,GAAG,YAAE,CAAC,OAAO,EAAE,CAAC;AAE7B,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,yBAAyB,GAAG,cAAI,CAAC,IAAI,CACzC,IAAI,EACJ,qBAAqB,EACrB,OAAO,EACP,WAAW,EACX,QAAQ,EACR,8BAA8B,EAC9B,IAAI,CACL,CA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,CAClC,CAAC;KACH;IAED,IAAI,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;QACnC,IAAA,YAAK,EACH,iCAAiC,eAAK,CAAC,KAAK,CAC1C,OAAO,CACR,wDAAwD,IAAI,wBAAwB,CACtF,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAtDD,6BAsDC;AAED,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,QAAQ,QAAQ,EAAE;QAChB,KAAK,OAAO,CAAC,CAAC;YACZ,OAAO,yBAAyB,CAAC;SAClC;QAED,KAAK,OAAO,CAAC,CAAC;YACZ,OAAO,uBAAuB,CAAC;SAChC;QAED,OAAO,CAAC,CAAC;YACP,IAAA,YAAK,EACH,gEAAgE,eAAK,CAAC,KAAK,CACzE,QAAQ,CACT,EAAE,CACJ,CAAC;YACF,OAAO,EAAE,CAAC;SACX;KACF;AACH,CAAC"}
|
|
@@ -28,13 +28,13 @@ async function init(argv) {
|
|
|
28
28
|
// Begin the creation of the new mod
|
|
29
29
|
(0, createMod_1.default)(projectName, projectPath, createNewDir, modsDirectory, saveSlot);
|
|
30
30
|
console.log(`Successfully created mod: ${chalk_1.default.green(projectName)}`);
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
(
|
|
34
|
-
await (0, promptVSCode_1.default)(projectPath, argv);
|
|
31
|
+
const VSCodeCommand = getVSCodeCommand();
|
|
32
|
+
if (VSCodeCommand === null) {
|
|
33
|
+
console.log('VSCode does not seem to be installed. (The "code" command is not in the path.) Skipping VSCode-related things.');
|
|
35
34
|
}
|
|
36
35
|
else {
|
|
37
|
-
|
|
36
|
+
(0, installVSCodeExtensions_1.default)(projectPath, VSCodeCommand);
|
|
37
|
+
await (0, promptVSCode_1.default)(projectPath, argv, VSCodeCommand);
|
|
38
38
|
}
|
|
39
39
|
// Finished
|
|
40
40
|
let commandsToType = "";
|
|
@@ -45,4 +45,12 @@ async function init(argv) {
|
|
|
45
45
|
console.log(`Now, start IsaacScript by typing ${commandsToType}.`);
|
|
46
46
|
}
|
|
47
47
|
exports.default = init;
|
|
48
|
+
function getVSCodeCommand() {
|
|
49
|
+
for (const VSCodeCommand of ["code", "codium", "code-oss"]) {
|
|
50
|
+
if (command_exists_1.default.sync(VSCodeCommand)) {
|
|
51
|
+
return VSCodeCommand;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
48
56
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../src/commands/init/init.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,oEAA2C;AAC3C,gDAAwB;AACxB,+CAAsC;AACtC,0FAAkE;AAClE,kFAA0D;AAC1D,wFAAgE;AAChE,4DAAoC;AACpC,8DAAsC;AACtC,sEAA8C;AAC9C,wFAAgE;AAChE,sEAA8C;AAC9C,kEAA0C;AAE3B,KAAK,UAAU,IAAI,CAChC,IAA6B;IAE7B,sEAAsE;IACtE,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,GAAG,MAAM,IAAA,wBAAc,EAAC,IAAI,CAAC,CAAC;IAC/D,MAAM,IAAA,kCAAwB,EAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAG,MAAM,IAAA,oBAAU,EAAC,IAAI,CAAC,CAAC;IAC7C,IAAA,8BAAoB,EAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,cAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,IAAA,iCAAuB,EAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAc,EAAC,IAAI,CAAC,CAAC;IAE5C,oCAAoC;IACpC,IAAA,mBAAS,EAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,CAAC,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gH,CACjH,CAAC;KACH;SAAM;QACL,IAAA,iCAAuB,EAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACpD,MAAM,IAAA,sBAAY,EAAC,WAAW,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;KACtD;IAED,WAAW;IACX,IAAI,cAAc,GAAG,EAAE,CAAC;IACxB,IAAI,WAAW,KAAK,eAAG,EAAE;QACvB,cAAc,IAAI,IAAI,eAAK,CAAC,KAAK,CAAC,MAAM,WAAW,EAAE,CAAC,QAAQ,CAAC;KAChE;IACD,cAAc,IAAI,IAAI,eAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,oCAAoC,cAAc,GAAG,CAAC,CAAC;AACrE,CAAC;AAjCD,uBAiCC;AAED,SAAS,gBAAgB;IACvB,KAAK,MAAM,aAAa,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE;QAC1D,IAAI,wBAAa,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;YACrC,OAAO,aAAa,CAAC;SACtB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -27,10 +27,10 @@ const JSONC = __importStar(require("jsonc-parser"));
|
|
|
27
27
|
const path_1 = __importDefault(require("path"));
|
|
28
28
|
const file = __importStar(require("../../file"));
|
|
29
29
|
const util_1 = require("../../util");
|
|
30
|
-
function installVSCodeExtensions(projectPath) {
|
|
30
|
+
function installVSCodeExtensions(projectPath, VSCodeCommand) {
|
|
31
31
|
const extensions = getExtensionsFromJSON(projectPath);
|
|
32
32
|
for (const extensionName of extensions) {
|
|
33
|
-
(0, util_1.execShell)(
|
|
33
|
+
(0, util_1.execShell)(VSCodeCommand, ["--install-extension", extensionName]);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.default = installVSCodeExtensions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installVSCodeExtensions.js","sourceRoot":"","sources":["../../../../src/commands/init/installVSCodeExtensions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,oDAAsC;AACtC,gDAAwB;AACxB,iDAAmC;AACnC,qCAA8C;AAE9C,SAAwB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"installVSCodeExtensions.js","sourceRoot":"","sources":["../../../../src/commands/init/installVSCodeExtensions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,oDAAsC;AACtC,gDAAwB;AACxB,iDAAmC;AACnC,qCAA8C;AAE9C,SAAwB,uBAAuB,CAC7C,WAAmB,EACnB,aAAqB;IAErB,MAAM,UAAU,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACtD,KAAK,MAAM,aAAa,IAAI,UAAU,EAAE;QACtC,IAAA,gBAAS,EAAC,aAAa,EAAE,CAAC,qBAAqB,EAAE,aAAa,CAAC,CAAC,CAAC;KAClE;AACH,CAAC;AARD,0CAQC;AAMD,SAAS,qBAAqB,CAAC,WAAmB;IAChD,MAAM,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAClC,WAAW,EACX,SAAS,EACT,iBAAiB,CAClB,CAAC;IAEF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE;QACpC,OAAO,EAAE,CAAC;KACX;IAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAExD,IAAI,cAA8B,CAAC;IACnC,IAAI;QACF,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAmB,CAAC;KACnE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,YAAK,EACH,wBAAwB,eAAK,CAAC,KAAK,CAAC,kBAAkB,CAAC,SAAS,EAChE,GAAG,CACJ,CAAC;KACH;IAED,OAAO,cAAc,CAAC,eAAe,CAAC;AACxC,CAAC"}
|
|
@@ -7,11 +7,11 @@ const path_1 = __importDefault(require("path"));
|
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const constants_1 = require("../../constants");
|
|
9
9
|
const util_1 = require("../../util");
|
|
10
|
-
async function promptVSCode(projectPath, argv) {
|
|
10
|
+
async function promptVSCode(projectPath, argv, VSCodeCommand) {
|
|
11
11
|
if (argv.vscode !== undefined) {
|
|
12
12
|
// They supplied the "--vscode" command-line flag,
|
|
13
13
|
// so there is no need to prompt the user
|
|
14
|
-
openVSCode(projectPath);
|
|
14
|
+
openVSCode(projectPath, VSCodeCommand);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
const response = await (0, prompts_1.default)({
|
|
@@ -21,12 +21,12 @@ async function promptVSCode(projectPath, argv) {
|
|
|
21
21
|
initial: true,
|
|
22
22
|
});
|
|
23
23
|
if (response.VSCode === true) {
|
|
24
|
-
openVSCode(projectPath);
|
|
24
|
+
openVSCode(projectPath, VSCodeCommand);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.default = promptVSCode;
|
|
28
|
-
function openVSCode(projectPath) {
|
|
28
|
+
function openVSCode(projectPath, VSCodeCommand) {
|
|
29
29
|
const MAIN_TS_PATH = path_1.default.join(projectPath, "src", constants_1.MAIN_TS);
|
|
30
|
-
(0, util_1.execShell)(
|
|
30
|
+
(0, util_1.execShell)(VSCodeCommand, [projectPath, MAIN_TS_PATH]);
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=promptVSCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promptVSCode.js","sourceRoot":"","sources":["../../../../src/commands/init/promptVSCode.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,sDAA8B;AAC9B,+CAA0C;AAC1C,qCAAuC;AAExB,KAAK,UAAU,YAAY,CACxC,WAAmB,EACnB,IAA6B;
|
|
1
|
+
{"version":3,"file":"promptVSCode.js","sourceRoot":"","sources":["../../../../src/commands/init/promptVSCode.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,sDAA8B;AAC9B,+CAA0C;AAC1C,qCAAuC;AAExB,KAAK,UAAU,YAAY,CACxC,WAAmB,EACnB,IAA6B,EAC7B,aAAqB;IAErB,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;QAC7B,kDAAkD;QAClD,yCAAyC;QACzC,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACvC,OAAO;KACR;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,iBAAO,EAAC;QAC7B,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,qDAAqD;QAC9D,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,EAAE;QAC5B,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;KACxC;AACH,CAAC;AAtBD,+BAsBC;AAED,SAAS,UAAU,CAAC,WAAmB,EAAE,aAAqB;IAC5D,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,mBAAO,CAAC,CAAC;IAC5D,IAAA,gBAAS,EAAC,aAAa,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/src/file.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.writeTry = exports.write = exports.touch = exports.read = exports.makeDir = exports.
|
|
6
|
+
exports.writeTry = exports.write = exports.touch = exports.read = exports.makeDir = exports.isSubDirOf = exports.isDir = exports.getDirList = exports.exists = exports.deleteFile = exports.deleteDir = exports.copy = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -65,7 +65,7 @@ exports.getDirList = getDirList;
|
|
|
65
65
|
function getFileStats(filePath) {
|
|
66
66
|
let fileStats;
|
|
67
67
|
try {
|
|
68
|
-
fileStats = fs_extra_1.default.
|
|
68
|
+
fileStats = fs_extra_1.default.statSync(filePath);
|
|
69
69
|
}
|
|
70
70
|
catch (err) {
|
|
71
71
|
(0, util_1.error)(`Failed to get the file stats for "${chalk_1.default.green(filePath)}":`, err);
|
|
@@ -82,11 +82,6 @@ function isSubDirOf(dir, parent) {
|
|
|
82
82
|
return (relative !== "" && !relative.startsWith("..") && !path_1.default.isAbsolute(relative));
|
|
83
83
|
}
|
|
84
84
|
exports.isSubDirOf = isSubDirOf;
|
|
85
|
-
function isSymbolicLink(filePath) {
|
|
86
|
-
const fileStats = getFileStats(filePath);
|
|
87
|
-
return fileStats.isSymbolicLink();
|
|
88
|
-
}
|
|
89
|
-
exports.isSymbolicLink = isSymbolicLink;
|
|
90
85
|
function makeDir(dirPath) {
|
|
91
86
|
try {
|
|
92
87
|
fs_extra_1.default.mkdirSync(dirPath);
|
package/dist/src/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/file.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,wDAA0B;AAC1B,gDAAwB;AACxB,iCAA+B;AAE/B,SAAgB,IAAI,CAAC,OAAe,EAAE,OAAe;IACnD,IAAI;QACF,0EAA0E;QAC1E,kBAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE;YAC5B,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;KACJ;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,YAAK,EACH,6BAA6B,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,eAAK,CAAC,KAAK,CACnE,OAAO,CACR,IAAI,EACL,GAAG,C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AE,IAAY;IACrD,kBAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC;AAFD,4BAEC"}
|
package/dist/src/monkeyPatch.js
CHANGED
|
@@ -26,9 +26,27 @@ exports.monkeyPatchMainLua = void 0;
|
|
|
26
26
|
const path_1 = __importDefault(require("path"));
|
|
27
27
|
const constants_1 = require("./constants");
|
|
28
28
|
const file = __importStar(require("./file"));
|
|
29
|
+
const mainLuaHeader = `--[[
|
|
30
|
+
|
|
31
|
+
This Isaac mod was created with the IsaacScript tool.
|
|
32
|
+
|
|
33
|
+
The Lua code in this file was automatically generated from higher-level TypeScript code and might be
|
|
34
|
+
hard to read. If you want to understand how the code in this mod works, you should read the actual
|
|
35
|
+
TypeScript source code directly instead of trying to parse this file. Usually, the link to the
|
|
36
|
+
source code can be found in the mod's description on the Steam Workshop. If not, you can ask the mod
|
|
37
|
+
author directly if the source code is publicly available.
|
|
38
|
+
|
|
39
|
+
IsaacScript provides a lot of advantages over using raw Lua. For more information about the tool,
|
|
40
|
+
see the official website: https://isaacscript.github.io/
|
|
41
|
+
|
|
42
|
+
--]]
|
|
43
|
+
|
|
44
|
+
`;
|
|
29
45
|
// Some TSTL objects (such as Map and Set) are written as global variables,
|
|
30
46
|
// which can cause multiple mods written with IsaacScript to trample on one another
|
|
31
47
|
// Until TSTL has an official fix, monkey patch this
|
|
48
|
+
// We also make sure of this function to compose a stock comment header for curious people looking
|
|
49
|
+
// at the transpiled Lua code
|
|
32
50
|
function monkeyPatchMainLua(targetModDirectory) {
|
|
33
51
|
const mainLuaPath = path_1.default.join(targetModDirectory, constants_1.MAIN_LUA);
|
|
34
52
|
let mainLua = file.read(mainLuaPath);
|
|
@@ -36,6 +54,7 @@ function monkeyPatchMainLua(targetModDirectory) {
|
|
|
36
54
|
mainLua = mainLua.replace("WeakSet = (function", "WeakSet = WeakSet or (function");
|
|
37
55
|
mainLua = mainLua.replace("Map = (function", "Map = Map or (function");
|
|
38
56
|
mainLua = mainLua.replace("Set = (function", "Set = Set or (function");
|
|
57
|
+
mainLua = mainLuaHeader + mainLua;
|
|
39
58
|
file.write(mainLuaPath, mainLua);
|
|
40
59
|
}
|
|
41
60
|
exports.monkeyPatchMainLua = monkeyPatchMainLua;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monkeyPatch.js","sourceRoot":"","sources":["../../src/monkeyPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,2CAAuC;AACvC,6CAA+B;AAE/B,2EAA2E;AAC3E,mFAAmF;AACnF,oDAAoD;AACpD,SAAgB,kBAAkB,CAAC,kBAA0B;IAC3D,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,oBAAQ,CAAC,CAAC;IAC5D,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAErC,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,qBAAqB,EACrB,gCAAgC,CACjC,CAAC;IACF,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,qBAAqB,EACrB,gCAAgC,CACjC,CAAC;IACF,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,wBAAwB,CAAC,CAAC;IACvE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,wBAAwB,CAAC,CAAC;IAEvE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;
|
|
1
|
+
{"version":3,"file":"monkeyPatch.js","sourceRoot":"","sources":["../../src/monkeyPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,2CAAuC;AACvC,6CAA+B;AAE/B,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;CAerB,CAAC;AAEF,2EAA2E;AAC3E,mFAAmF;AACnF,oDAAoD;AACpD,kGAAkG;AAClG,6BAA6B;AAC7B,SAAgB,kBAAkB,CAAC,kBAA0B;IAC3D,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,oBAAQ,CAAC,CAAC;IAC5D,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAErC,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,qBAAqB,EACrB,gCAAgC,CACjC,CAAC;IACF,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,qBAAqB,EACrB,gCAAgC,CACjC,CAAC;IACF,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,wBAAwB,CAAC,CAAC;IACvE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,wBAAwB,CAAC,CAAC;IAEvE,OAAO,GAAG,aAAa,GAAG,OAAO,CAAC;IAElC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;AAlBD,gDAkBC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -42,11 +42,6 @@ export default async function getModsDir(
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const defaultModsPath = getDefaultModsPath(process.platform);
|
|
45
|
-
if (file.exists(defaultModsPath) && file.isSymbolicLink(defaultModsPath)) {
|
|
46
|
-
error(
|
|
47
|
-
'Error: Your mods directory appears to be a symbolic link, which is not currently supported. If you want to get around this, try specifying a directory with the "--mods-directory" command line flag, but the rest of the program may not work properly.',
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
45
|
|
|
51
46
|
if (file.exists(defaultModsPath) && file.isDir(defaultModsPath)) {
|
|
52
47
|
return defaultModsPath;
|
|
@@ -28,14 +28,14 @@ export default async function init(
|
|
|
28
28
|
createMod(projectName, projectPath, createNewDir, modsDirectory, saveSlot);
|
|
29
29
|
console.log(`Successfully created mod: ${chalk.green(projectName)}`);
|
|
30
30
|
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
installVSCodeExtensions(projectPath);
|
|
34
|
-
await promptVSCode(projectPath, argv);
|
|
35
|
-
} else {
|
|
31
|
+
const VSCodeCommand = getVSCodeCommand();
|
|
32
|
+
if (VSCodeCommand === null) {
|
|
36
33
|
console.log(
|
|
37
34
|
'VSCode does not seem to be installed. (The "code" command is not in the path.) Skipping VSCode-related things.',
|
|
38
35
|
);
|
|
36
|
+
} else {
|
|
37
|
+
installVSCodeExtensions(projectPath, VSCodeCommand);
|
|
38
|
+
await promptVSCode(projectPath, argv, VSCodeCommand);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// Finished
|
|
@@ -46,3 +46,13 @@ export default async function init(
|
|
|
46
46
|
commandsToType += `"${chalk.green("npx isaacscript")}"`;
|
|
47
47
|
console.log(`Now, start IsaacScript by typing ${commandsToType}.`);
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
function getVSCodeCommand() {
|
|
51
|
+
for (const VSCodeCommand of ["code", "codium", "code-oss"]) {
|
|
52
|
+
if (commandExists.sync(VSCodeCommand)) {
|
|
53
|
+
return VSCodeCommand;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
@@ -4,10 +4,13 @@ import path from "path";
|
|
|
4
4
|
import * as file from "../../file";
|
|
5
5
|
import { error, execShell } from "../../util";
|
|
6
6
|
|
|
7
|
-
export default function installVSCodeExtensions(
|
|
7
|
+
export default function installVSCodeExtensions(
|
|
8
|
+
projectPath: string,
|
|
9
|
+
VSCodeCommand: string,
|
|
10
|
+
): void {
|
|
8
11
|
const extensions = getExtensionsFromJSON(projectPath);
|
|
9
12
|
for (const extensionName of extensions) {
|
|
10
|
-
execShell(
|
|
13
|
+
execShell(VSCodeCommand, ["--install-extension", extensionName]);
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -6,11 +6,12 @@ import { execShell } from "../../util";
|
|
|
6
6
|
export default async function promptVSCode(
|
|
7
7
|
projectPath: string,
|
|
8
8
|
argv: Record<string, unknown>,
|
|
9
|
+
VSCodeCommand: string,
|
|
9
10
|
): Promise<void> {
|
|
10
11
|
if (argv.vscode !== undefined) {
|
|
11
12
|
// They supplied the "--vscode" command-line flag,
|
|
12
13
|
// so there is no need to prompt the user
|
|
13
|
-
openVSCode(projectPath);
|
|
14
|
+
openVSCode(projectPath, VSCodeCommand);
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -22,11 +23,11 @@ export default async function promptVSCode(
|
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
if (response.VSCode === true) {
|
|
25
|
-
openVSCode(projectPath);
|
|
26
|
+
openVSCode(projectPath, VSCodeCommand);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
function openVSCode(projectPath: string) {
|
|
30
|
+
function openVSCode(projectPath: string, VSCodeCommand: string) {
|
|
30
31
|
const MAIN_TS_PATH = path.join(projectPath, "src", MAIN_TS);
|
|
31
|
-
execShell(
|
|
32
|
+
execShell(VSCodeCommand, [projectPath, MAIN_TS_PATH]);
|
|
32
33
|
}
|
package/src/file.ts
CHANGED
|
@@ -65,7 +65,7 @@ export function getDirList(dirPath: string): string[] {
|
|
|
65
65
|
function getFileStats(filePath: string): fs.Stats {
|
|
66
66
|
let fileStats: fs.Stats;
|
|
67
67
|
try {
|
|
68
|
-
fileStats = fs.
|
|
68
|
+
fileStats = fs.statSync(filePath);
|
|
69
69
|
} catch (err) {
|
|
70
70
|
error(`Failed to get the file stats for "${chalk.green(filePath)}":`, err);
|
|
71
71
|
}
|
|
@@ -85,11 +85,6 @@ export function isSubDirOf(dir: string, parent: string): boolean {
|
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export function isSymbolicLink(filePath: string): boolean {
|
|
89
|
-
const fileStats = getFileStats(filePath);
|
|
90
|
-
return fileStats.isSymbolicLink();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
88
|
export function makeDir(dirPath: string): void {
|
|
94
89
|
try {
|
|
95
90
|
fs.mkdirSync(dirPath);
|
package/src/monkeyPatch.ts
CHANGED
|
@@ -2,9 +2,28 @@ import path from "path";
|
|
|
2
2
|
import { MAIN_LUA } from "./constants";
|
|
3
3
|
import * as file from "./file";
|
|
4
4
|
|
|
5
|
+
const mainLuaHeader = `--[[
|
|
6
|
+
|
|
7
|
+
This Isaac mod was created with the IsaacScript tool.
|
|
8
|
+
|
|
9
|
+
The Lua code in this file was automatically generated from higher-level TypeScript code and might be
|
|
10
|
+
hard to read. If you want to understand how the code in this mod works, you should read the actual
|
|
11
|
+
TypeScript source code directly instead of trying to parse this file. Usually, the link to the
|
|
12
|
+
source code can be found in the mod's description on the Steam Workshop. If not, you can ask the mod
|
|
13
|
+
author directly if the source code is publicly available.
|
|
14
|
+
|
|
15
|
+
IsaacScript provides a lot of advantages over using raw Lua. For more information about the tool,
|
|
16
|
+
see the official website: https://isaacscript.github.io/
|
|
17
|
+
|
|
18
|
+
--]]
|
|
19
|
+
|
|
20
|
+
`;
|
|
21
|
+
|
|
5
22
|
// Some TSTL objects (such as Map and Set) are written as global variables,
|
|
6
23
|
// which can cause multiple mods written with IsaacScript to trample on one another
|
|
7
24
|
// Until TSTL has an official fix, monkey patch this
|
|
25
|
+
// We also make sure of this function to compose a stock comment header for curious people looking
|
|
26
|
+
// at the transpiled Lua code
|
|
8
27
|
export function monkeyPatchMainLua(targetModDirectory: string): void {
|
|
9
28
|
const mainLuaPath = path.join(targetModDirectory, MAIN_LUA);
|
|
10
29
|
let mainLua = file.read(mainLuaPath);
|
|
@@ -20,5 +39,7 @@ export function monkeyPatchMainLua(targetModDirectory: string): void {
|
|
|
20
39
|
mainLua = mainLua.replace("Map = (function", "Map = Map or (function");
|
|
21
40
|
mainLua = mainLua.replace("Set = (function", "Set = Set or (function");
|
|
22
41
|
|
|
42
|
+
mainLua = mainLuaHeader + mainLua;
|
|
43
|
+
|
|
23
44
|
file.write(mainLuaPath, mainLua);
|
|
24
45
|
}
|