isaacscript 1.2.26 → 1.2.29

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.
Files changed (55) hide show
  1. package/dist/package.json +5 -5
  2. package/dist/src/commands/copy/copy.js +0 -1
  3. package/dist/src/commands/copy/copy.js.map +1 -1
  4. package/dist/src/commands/init/checkIfProjectPathExists.js +14 -8
  5. package/dist/src/commands/init/checkIfProjectPathExists.js.map +1 -1
  6. package/dist/src/commands/init/checkModSubdirectory.js +2 -2
  7. package/dist/src/commands/init/checkModSubdirectory.js.map +1 -1
  8. package/dist/src/commands/init/checkModTargetDirectory.js +12 -6
  9. package/dist/src/commands/init/checkModTargetDirectory.js.map +1 -1
  10. package/dist/src/commands/init/createMod.js +11 -96
  11. package/dist/src/commands/init/createMod.js.map +1 -1
  12. package/dist/src/commands/init/getProjectPath.js +13 -4
  13. package/dist/src/commands/init/getProjectPath.js.map +1 -1
  14. package/dist/src/commands/init/git.js +176 -0
  15. package/dist/src/commands/init/git.js.map +1 -0
  16. package/dist/src/commands/init/init.js +11 -6
  17. package/dist/src/commands/init/init.js.map +1 -1
  18. package/dist/src/commands/init/promptSaveSlot.js +4 -1
  19. package/dist/src/commands/init/promptSaveSlot.js.map +1 -1
  20. package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +0 -5
  21. package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +1 -1
  22. package/dist/src/commands/publish/publish.js +3 -20
  23. package/dist/src/commands/publish/publish.js.map +1 -1
  24. package/dist/src/configFile.js +4 -3
  25. package/dist/src/configFile.js.map +1 -1
  26. package/dist/src/parseArgs.js +5 -0
  27. package/dist/src/parseArgs.js.map +1 -1
  28. package/dist/src/prompt.js +1 -0
  29. package/dist/src/prompt.js.map +1 -1
  30. package/file-templates/static/.github/workflows/ci.yml +3 -3
  31. package/{src → file-templates/static}/plugins/addCrashDebugStatements.ts +0 -0
  32. package/file-templates/static/plugins/addIsaacScriptCommentHeader.ts +35 -0
  33. package/file-templates/static/tsconfig.json +8 -0
  34. package/isaacscript-watcher/metadata.xml +5 -5
  35. package/package.json +5 -5
  36. package/src/commands/copy/copy.ts +0 -1
  37. package/src/commands/init/checkIfProjectPathExists.ts +19 -12
  38. package/src/commands/init/checkModSubdirectory.ts +2 -2
  39. package/src/commands/init/checkModTargetDirectory.ts +17 -11
  40. package/src/commands/init/createMod.ts +21 -170
  41. package/src/commands/init/getProjectPath.ts +14 -4
  42. package/src/commands/init/git.ts +248 -0
  43. package/src/commands/init/init.ts +21 -6
  44. package/src/commands/init/promptSaveSlot.ts +5 -0
  45. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +0 -6
  46. package/src/commands/publish/publish.ts +1 -25
  47. package/src/configFile.ts +5 -4
  48. package/src/exec.ts +1 -1
  49. package/src/parseArgs.ts +6 -0
  50. package/src/prompt.ts +1 -0
  51. package/dist/src/monkeyPatch.js +0 -82
  52. package/dist/src/monkeyPatch.js.map +0 -1
  53. package/dist/src/plugins/addCrashDebugStatements.js +0 -44
  54. package/dist/src/plugins/addCrashDebugStatements.js.map +0 -1
  55. package/src/monkeyPatch.ts +0 -62
package/src/configFile.ts CHANGED
@@ -10,24 +10,25 @@ import { error } from "./utils";
10
10
 
11
11
  export async function get(argv: Record<string, unknown>): Promise<Config> {
12
12
  const verbose = argv.verbose === true;
13
+ const yes = argv.yes === true;
13
14
 
14
15
  const existingConfig = readExistingConfig();
15
- if (existingConfig !== null) {
16
+ if (existingConfig !== undefined) {
16
17
  return existingConfig;
17
18
  }
18
19
 
19
20
  // No config file exists, so prompt the user for some information and create one
20
21
  const modsDirectory = await getModsDir(argv);
21
- const saveSlot = await promptSaveSlot(argv);
22
+ const saveSlot = await promptSaveSlot(argv, yes);
22
23
  const config = createObject(modsDirectory, saveSlot);
23
24
  createFile(CWD, config, verbose);
24
25
 
25
26
  return config;
26
27
  }
27
28
 
28
- function readExistingConfig(): Config | null {
29
+ function readExistingConfig(): Config | undefined {
29
30
  if (!file.exists(CONFIG_FILE_PATH)) {
30
- return null;
31
+ return undefined;
31
32
  }
32
33
 
33
34
  const configRaw = file.read(CONFIG_FILE_PATH);
package/src/exec.ts CHANGED
@@ -59,7 +59,7 @@ export function execShell(
59
59
  verbose = false,
60
60
  allowFailure = false,
61
61
  cwd = CWD,
62
- ): [number, string] {
62
+ ): [exitStatus: number, stdout: string] {
63
63
  // On Windows, "spawnSync()" will not account for spaces in arguments
64
64
  // Thus, wrap everything in a double quote
65
65
  // This will cause arguments that naturally have double quotes to fail
package/src/parseArgs.ts CHANGED
@@ -32,6 +32,12 @@ export function parseArgs(): Record<string, unknown> {
32
32
  `Initialize a new ${PROJECT_NAME} mod.`,
33
33
  (builder) =>
34
34
  builder
35
+ .option("yes", {
36
+ alias: "y",
37
+ type: "boolean",
38
+ description:
39
+ 'Answer yes to every dialog option, similar to how "npm init --yes" works.',
40
+ })
35
41
  .option("use-current-dir", {
36
42
  alias: "u",
37
43
  type: "boolean",
package/src/prompt.ts CHANGED
@@ -63,6 +63,7 @@ export async function getInputYesNo(
63
63
  return false;
64
64
  }
65
65
 
66
+ /** Returns trimmed input. */
66
67
  export async function getInputString(
67
68
  msg: string,
68
69
  defaultValue?: string,
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const path_1 = __importDefault(require("path"));
30
- const constants_1 = require("./constants");
31
- const file = __importStar(require("./file"));
32
- const INFORMATIONAL_HEADER = `--[[
33
-
34
- This Isaac mod was created with the IsaacScript tool.
35
-
36
- The Lua code in this file was automatically generated from higher-level TypeScript code and might be
37
- hard to read. If you want to understand how the code in this mod works, you should read the actual
38
- TypeScript source code directly instead of trying to parse this file. Usually, the link to the
39
- source code can be found in the mod's description on the Steam Workshop. If not, you can ask the mod
40
- author directly if the source code is publicly available.
41
-
42
- IsaacScript provides a lot of advantages over using raw Lua. For more information about the tool,
43
- see the official website: https://isaacscript.github.io/
44
-
45
- --]]
46
-
47
- `;
48
- const MAIN_LUA_REPLACEMENTS = [
49
- // For TSTL v1.2.X-v1.3.3
50
- // (fixed with GlassBrick's PR)
51
- ["WeakMap = __TS__Class()", "WeakMap = WeakMap or __TS__Class()"],
52
- ["WeakSet = __TS__Class()", "WeakSet = WeakSet or __TS__Class()"],
53
- ["Map = __TS__Class()", "Map = Map or __TS__Class()"],
54
- ["Set = __TS__Class()", "Set = Set or __TS__Class()"],
55
- ];
56
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
- function monkeyPatchMainLua(targetModDirectory, verbose) {
58
- const mainLuaPath = path_1.default.join(targetModDirectory, constants_1.MAIN_LUA);
59
- const mainLua = file.read(mainLuaPath);
60
- // mainLua = patchInformationalHeader(mainLua);
61
- // mainLua = patchGlobalObjects(mainLua);
62
- file.write(mainLuaPath, mainLua, verbose);
63
- }
64
- // Add an informational header for people who happen to be browsing the Lua output
65
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
66
- function patchInformationalHeader(mainLua) {
67
- return INFORMATIONAL_HEADER + mainLua;
68
- }
69
- // Some TSTL objects (such as Map and Set) are written as global variables,
70
- // which can cause multiple mods written with IsaacScript to trample on one another
71
- // Until TSTL has an official fix, monkey patch this
72
- // We also make sure of this function to compose a stock comment header for curious people looking
73
- // at the transpiled Lua code
74
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
75
- function patchGlobalObjects(originalMainLua) {
76
- let mainLua = originalMainLua;
77
- for (const [findString, replaceString] of MAIN_LUA_REPLACEMENTS) {
78
- mainLua = mainLua.replace(findString, replaceString);
79
- }
80
- return mainLua;
81
- }
82
- //# sourceMappingURL=monkeyPatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"monkeyPatch.js","sourceRoot":"","sources":["../../src/monkeyPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,2CAAuC;AACvC,6CAA+B;AAE/B,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;CAe5B,CAAC;AAEF,MAAM,qBAAqB,GAAG;IAC5B,yBAAyB;IACzB,+BAA+B;IAC/B,CAAC,yBAAyB,EAAE,oCAAoC,CAAC;IACjE,CAAC,yBAAyB,EAAE,oCAAoC,CAAC;IACjE,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;IACrD,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;CACtD,CAAC;AAEF,6DAA6D;AAC7D,SAAS,kBAAkB,CAAC,kBAA0B,EAAE,OAAgB;IACtE,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,oBAAQ,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEvC,+CAA+C;IAC/C,yCAAyC;IAEzC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,kFAAkF;AAClF,6DAA6D;AAC7D,SAAS,wBAAwB,CAAC,OAAe;IAC/C,OAAO,oBAAoB,GAAG,OAAO,CAAC;AACxC,CAAC;AAED,2EAA2E;AAC3E,mFAAmF;AACnF,oDAAoD;AACpD,kGAAkG;AAClG,6BAA6B;AAC7B,6DAA6D;AAC7D,SAAS,kBAAkB,CAAC,eAAuB;IACjD,IAAI,OAAO,GAAG,eAAe,CAAC;IAE9B,KAAK,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,qBAAqB,EAAE;QAC/D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;KACtD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const crypto = __importStar(require("crypto"));
27
- const tstl = __importStar(require("typescript-to-lua"));
28
- class CustomPrinter extends tstl.LuaPrinter {
29
- printStatement(statement) {
30
- const uuid = crypto.randomUUID();
31
- const debugLineToInsert = `Isaac.DebugString("CRASH DEBUG ${uuid}")\n`;
32
- const originalResult = super.printStatement(statement);
33
- return this.createSourceNode(statement, [
34
- debugLineToInsert,
35
- originalResult,
36
- ]);
37
- }
38
- }
39
- const plugin = {
40
- printer: (program, emitHost, fileName, file) => new CustomPrinter(emitHost, program, fileName).print(file),
41
- };
42
- // ts-prune-ignore-next
43
- exports.default = plugin;
44
- //# sourceMappingURL=addCrashDebugStatements.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addCrashDebugStatements.js","sourceRoot":"","sources":["../../../src/plugins/addCrashDebugStatements.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAGjC,wDAA0C;AAE1C,MAAM,aAAc,SAAQ,IAAI,CAAC,UAAU;IACzC,cAAc,CAAC,SAAyB;QACtC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,iBAAiB,GAAG,kCAAkC,IAAI,MAAM,CAAC;QACvE,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE;YACtC,iBAAiB;YACjB,cAAc;SACf,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,MAAM,GAAgB;IAC1B,OAAO,EAAE,CACP,OAAmB,EACnB,QAAuB,EACvB,QAAgB,EAChB,IAAe,EACf,EAAE,CAAC,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;CAChE,CAAC;AAEF,uBAAuB;AACvB,kBAAe,MAAM,CAAC"}
@@ -1,62 +0,0 @@
1
- import path from "path";
2
- import { MAIN_LUA } from "./constants";
3
- import * as file from "./file";
4
-
5
- const INFORMATIONAL_HEADER = `--[[
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
-
22
- const MAIN_LUA_REPLACEMENTS = [
23
- // For TSTL v1.2.X-v1.3.3
24
- // (fixed with GlassBrick's PR)
25
- ["WeakMap = __TS__Class()", "WeakMap = WeakMap or __TS__Class()"],
26
- ["WeakSet = __TS__Class()", "WeakSet = WeakSet or __TS__Class()"],
27
- ["Map = __TS__Class()", "Map = Map or __TS__Class()"],
28
- ["Set = __TS__Class()", "Set = Set or __TS__Class()"],
29
- ];
30
-
31
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
- function monkeyPatchMainLua(targetModDirectory: string, verbose: boolean) {
33
- const mainLuaPath = path.join(targetModDirectory, MAIN_LUA);
34
- const mainLua = file.read(mainLuaPath);
35
-
36
- // mainLua = patchInformationalHeader(mainLua);
37
- // mainLua = patchGlobalObjects(mainLua);
38
-
39
- file.write(mainLuaPath, mainLua, verbose);
40
- }
41
-
42
- // Add an informational header for people who happen to be browsing the Lua output
43
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
- function patchInformationalHeader(mainLua: string) {
45
- return INFORMATIONAL_HEADER + mainLua;
46
- }
47
-
48
- // Some TSTL objects (such as Map and Set) are written as global variables,
49
- // which can cause multiple mods written with IsaacScript to trample on one another
50
- // Until TSTL has an official fix, monkey patch this
51
- // We also make sure of this function to compose a stock comment header for curious people looking
52
- // at the transpiled Lua code
53
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
54
- function patchGlobalObjects(originalMainLua: string) {
55
- let mainLua = originalMainLua;
56
-
57
- for (const [findString, replaceString] of MAIN_LUA_REPLACEMENTS) {
58
- mainLua = mainLua.replace(findString, replaceString);
59
- }
60
-
61
- return mainLua;
62
- }