isaacscript 2.0.4 → 2.0.7

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 (150) hide show
  1. package/dist/src/commands/init/createMod.js +9 -9
  2. package/dist/src/commands/init/git.js +3 -3
  3. package/dist/src/commands/init/init.js +2 -2
  4. package/dist/src/commands/monitor/monitor.js +13 -13
  5. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +2 -2
  6. package/dist/src/configFile.js +1 -1
  7. package/dist/src/constants.js +12 -9
  8. package/dist/src/file.js +1 -1
  9. package/dist/src/main.js +3 -3
  10. package/dist/src/utils.js +5 -5
  11. package/dist/src/validateInIsaacScriptProject.js +1 -1
  12. package/package.json +11 -6
  13. package/.cspell-base.json +0 -38
  14. package/.cspell-check-unused.json +0 -7
  15. package/.cspell.json +0 -53
  16. package/.eslintrc.js +0 -28
  17. package/.gitattributes +0 -9
  18. package/.github/workflows/ci.yml +0 -47
  19. package/.prettierignore +0 -5
  20. package/.prettierrc.js +0 -42
  21. package/.vscode/extensions.json +0 -9
  22. package/.vscode/settings.json +0 -73
  23. package/build.sh +0 -30
  24. package/check-file-updates.sh +0 -57
  25. package/check-gitignore.sh +0 -26
  26. package/check-orphaned-words.sh +0 -53
  27. package/dist/package.json +0 -50
  28. package/dist/src/checkForWindowsTerminalBugs.js.map +0 -1
  29. package/dist/src/commands/copy/copy.js.map +0 -1
  30. package/dist/src/commands/init/checkIfProjectPathExists.js.map +0 -1
  31. package/dist/src/commands/init/checkModSubdirectory.js.map +0 -1
  32. package/dist/src/commands/init/checkModTargetDirectory.js.map +0 -1
  33. package/dist/src/commands/init/createMod.js.map +0 -1
  34. package/dist/src/commands/init/getModsDir.js.map +0 -1
  35. package/dist/src/commands/init/getProjectPath.js.map +0 -1
  36. package/dist/src/commands/init/git.js.map +0 -1
  37. package/dist/src/commands/init/init.js.map +0 -1
  38. package/dist/src/commands/init/installVSCodeExtensions.js.map +0 -1
  39. package/dist/src/commands/init/promptSaveSlot.js.map +0 -1
  40. package/dist/src/commands/init/promptVSCode.js.map +0 -1
  41. package/dist/src/commands/monitor/copyWatcherMod.js.map +0 -1
  42. package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +0 -1
  43. package/dist/src/commands/monitor/monitor.js.map +0 -1
  44. package/dist/src/commands/monitor/notifyGame.js.map +0 -1
  45. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +0 -1
  46. package/dist/src/commands/monitor/saveDatWriter/types.js.map +0 -1
  47. package/dist/src/commands/monitor/spawnSaveDatWriter.js.map +0 -1
  48. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +0 -1
  49. package/dist/src/commands/publish/publish.js.map +0 -1
  50. package/dist/src/configFile.js.map +0 -1
  51. package/dist/src/constants.js.map +0 -1
  52. package/dist/src/exec.js.map +0 -1
  53. package/dist/src/file.js.map +0 -1
  54. package/dist/src/main.js.map +0 -1
  55. package/dist/src/parseArgs.js.map +0 -1
  56. package/dist/src/prompt.js.map +0 -1
  57. package/dist/src/types/Command.js.map +0 -1
  58. package/dist/src/types/Config.js.map +0 -1
  59. package/dist/src/types/GitHubCLIHostsYAML.js.map +0 -1
  60. package/dist/src/utils.js.map +0 -1
  61. package/dist/src/validateInIsaacScriptProject.js.map +0 -1
  62. package/dist/src/validateNodeVersion.js.map +0 -1
  63. package/dist/src/validateOS.js.map +0 -1
  64. package/eslint-debug.sh +0 -11
  65. package/file-templates/dynamic/README.md +0 -3
  66. package/file-templates/dynamic/gitignore +0 -144
  67. package/file-templates/dynamic/main.ts +0 -19
  68. package/file-templates/dynamic/metadata.vdf +0 -6
  69. package/file-templates/dynamic/metadata.xml +0 -10
  70. package/file-templates/dynamic/package.json +0 -19
  71. package/file-templates/static/.cspell-check-unused.json +0 -9
  72. package/file-templates/static/.cspell.json.template +0 -9
  73. package/file-templates/static/.env_template +0 -2
  74. package/file-templates/static/.eslintrc.js +0 -24
  75. package/file-templates/static/.gitattributes +0 -9
  76. package/file-templates/static/.github/workflows/ci.yml +0 -53
  77. package/file-templates/static/.prettierignore +0 -14
  78. package/file-templates/static/.prettierrc.js +0 -42
  79. package/file-templates/static/.vscode/extensions.json +0 -10
  80. package/file-templates/static/.vscode/settings.json +0 -76
  81. package/file-templates/static/LICENSE +0 -674
  82. package/file-templates/static/build.sh +0 -15
  83. package/file-templates/static/check-orphaned-words.sh +0 -53
  84. package/file-templates/static/lint.sh +0 -39
  85. package/file-templates/static/nuke.sh +0 -18
  86. package/file-templates/static/plugins/addCrashDebugStatements.ts +0 -40
  87. package/file-templates/static/plugins/addIsaacScriptCommentHeader.ts +0 -37
  88. package/file-templates/static/plugins/noExtendedEnums.ts +0 -66
  89. package/file-templates/static/publish.sh +0 -10
  90. package/file-templates/static/run.sh +0 -10
  91. package/file-templates/static/src/bundleEntry.ts +0 -10
  92. package/file-templates/static/tsconfig.eslint.json +0 -11
  93. package/file-templates/static/tsconfig.json +0 -33
  94. package/file-templates/static/update.sh +0 -21
  95. package/file-templates/static-alt/.cspell-base.json +0 -38
  96. package/file-templates/static-alt/.cspell-check-unused-base.json +0 -7
  97. package/file-templates/static-alt/.prettierignore-base +0 -5
  98. package/file-templates/static-alt/.prettierrc-base.js +0 -30
  99. package/file-templates/static-alt/.vscode/extensions-typescript.json +0 -9
  100. package/file-templates/static-alt/.vscode/settings-typescript.json +0 -63
  101. package/isaacscript-watcher/.luacheckrc +0 -96
  102. package/isaacscript-watcher/README.md +0 -8
  103. package/isaacscript-watcher/main.lua +0 -270
  104. package/isaacscript-watcher/metadata.xml +0 -7
  105. package/isaacscript-watcher/resources/gfx/logo.anm2 +0 -27
  106. package/isaacscript-watcher/resources/gfx/logo.png +0 -0
  107. package/lint.sh +0 -38
  108. package/misc/logo.png +0 -0
  109. package/misc/mouseover.png +0 -0
  110. package/nuke.sh +0 -18
  111. package/publish.sh +0 -11
  112. package/src/checkForWindowsTerminalBugs.ts +0 -106
  113. package/src/commands/copy/copy.ts +0 -41
  114. package/src/commands/init/checkIfProjectPathExists.ts +0 -34
  115. package/src/commands/init/checkModSubdirectory.ts +0 -20
  116. package/src/commands/init/checkModTargetDirectory.ts +0 -42
  117. package/src/commands/init/createMod.ts +0 -196
  118. package/src/commands/init/getModsDir.ts +0 -107
  119. package/src/commands/init/getProjectPath.ts +0 -111
  120. package/src/commands/init/git.ts +0 -249
  121. package/src/commands/init/init.ts +0 -93
  122. package/src/commands/init/installVSCodeExtensions.ts +0 -47
  123. package/src/commands/init/promptSaveSlot.ts +0 -27
  124. package/src/commands/init/promptVSCode.ts +0 -33
  125. package/src/commands/monitor/copyWatcherMod.ts +0 -54
  126. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +0 -67
  127. package/src/commands/monitor/monitor.ts +0 -180
  128. package/src/commands/monitor/notifyGame.ts +0 -59
  129. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +0 -145
  130. package/src/commands/monitor/saveDatWriter/types.ts +0 -6
  131. package/src/commands/monitor/spawnSaveDatWriter.ts +0 -36
  132. package/src/commands/monitor/touchWatcherSaveDatFiles.ts +0 -20
  133. package/src/commands/publish/publish.ts +0 -392
  134. package/src/configFile.ts +0 -80
  135. package/src/constants.ts +0 -85
  136. package/src/exec.ts +0 -125
  137. package/src/file.ts +0 -235
  138. package/src/main.ts +0 -131
  139. package/src/parseArgs.ts +0 -127
  140. package/src/prompt.ts +0 -109
  141. package/src/types/Command.ts +0 -3
  142. package/src/types/Config.ts +0 -23
  143. package/src/types/GitHubCLIHostsYAML.ts +0 -7
  144. package/src/utils.ts +0 -92
  145. package/src/validateInIsaacScriptProject.ts +0 -35
  146. package/src/validateNodeVersion.ts +0 -29
  147. package/src/validateOS.ts +0 -20
  148. package/tsconfig.eslint.json +0 -11
  149. package/tsconfig.json +0 -21
  150. package/update.sh +0 -21
@@ -1,270 +0,0 @@
1
- -- Includes
2
- local json = require("json")
3
-
4
- -- Constants
5
- local MOD_NAME = "isaacscript-watcher"
6
- local RESTART_GAME_ON_RECOMPILATION = true
7
- local FRAMES_BEFORE_DISCONNECTED = 2 * 60 -- 2 seconds
8
- local FRAMES_BEFORE_TEXT_FADE = 2 * 60 -- 2 seconds
9
- local SPRITE_BOTTOM_RIGHT_OFFSET = Vector(-35, -60)
10
- -- (enough so that it does not overlap with a pocket active + 2 pocket items)
11
-
12
- -- Mod variables
13
- local saveData = {} -- An array of message objects.
14
- local restartFrame = 0
15
- local messageArray = {}
16
- local frameOfLastMsg = 0
17
- local frameOfLastSuccessfulLoad = 0
18
- local game = Game()
19
- local font = Font()
20
- font:Load("font/pftempestasevencondensed.fnt") -- A vanilla font good for this kind of text.
21
- local connected = false
22
- local sprite = nil
23
-
24
- local IsaacScriptWatcher = RegisterMod("IsaacScript Watcher", 1)
25
-
26
- -- On mod initialization, nuke the "save#.dat" folder to get rid of old messages that might be left
27
- -- there from IsaacScript.
28
- IsaacScriptWatcher:SaveData("")
29
-
30
- local function pushMessageArray(msg)
31
- frameOfLastMsg = Isaac.GetFrameCount()
32
-
33
- messageArray[#messageArray + 1] = msg
34
- if #messageArray > 10 then
35
- -- We only want to show 10 messages at a time.
36
- table.remove(messageArray, 1)
37
- end
38
- end
39
-
40
- local function getScreenBottomRightPos()
41
- local screenWidth = Isaac.GetScreenWidth();
42
- local screenHeight = Isaac.GetScreenHeight();
43
-
44
- return Vector(screenWidth, screenHeight)
45
- end
46
-
47
- -- ModCallbacks.MC_POST_RENDER (2)
48
- function IsaacScriptWatcher:PostRender()
49
- -- Don't do anything while fading in to a new run to prevent crashes.
50
- if game:GetFrameCount() < 1 then
51
- return
52
- end
53
-
54
- IsaacScriptWatcher:RenderSprite()
55
- IsaacScriptWatcher:RenderText()
56
- IsaacScriptWatcher:LoadSaveDat()
57
- IsaacScriptWatcher:CheckInput()
58
- IsaacScriptWatcher:CheckRestart()
59
- end
60
-
61
- function IsaacScriptWatcher:RenderSprite()
62
- -- Determine if IsaacScript is connected or not.
63
- local frameCount = Isaac.GetFrameCount()
64
- connected = frameCount - frameOfLastSuccessfulLoad <= FRAMES_BEFORE_DISCONNECTED
65
-
66
- -- Set the sprite
67
- if connected then
68
- if sprite == nil then
69
- sprite = Sprite()
70
- sprite:Load("gfx/logo.anm2", true)
71
- sprite:SetFrame("Default", 0)
72
- end
73
- else
74
- if sprite ~= nil then
75
- sprite = nil
76
- end
77
- end
78
-
79
- -- Render it
80
- if sprite ~= nil then
81
- local bottomRightPos = getScreenBottomRightPos()
82
- local position = bottomRightPos + SPRITE_BOTTOM_RIGHT_OFFSET
83
- sprite:RenderLayer(0, position)
84
- end
85
- end
86
-
87
- function IsaacScriptWatcher:RenderText()
88
- -- Don't draw IsaacScript text when custom consoles are open.
89
- if AwaitingTextInput then
90
- return
91
- end
92
-
93
- if frameOfLastMsg == 0 then
94
- return
95
- end
96
-
97
- if game:IsPaused() then
98
- return
99
- end
100
-
101
- if ModConfigMenu ~= nil then
102
- if ModConfigMenu.IsVisible then
103
- return
104
- end
105
- end
106
-
107
- -- Local variables
108
- local x = 60
109
- local y = 90
110
- local scale = 1
111
- local lineHeight = font:GetLineHeight() * scale
112
-
113
- -- The text will slowly fade out.
114
- local elapsedFrames = Isaac.GetFrameCount() - frameOfLastMsg
115
- local alpha
116
- if elapsedFrames <= FRAMES_BEFORE_TEXT_FADE then
117
- alpha = 1
118
- else
119
- local fadeFrames = elapsedFrames - FRAMES_BEFORE_TEXT_FADE
120
- alpha = 1 - (0.02 * fadeFrames)
121
- end
122
- if alpha <= 0 then
123
- frameOfLastMsg = 0
124
- return
125
- end
126
-
127
- local white = KColor(1, 1, 1, alpha)
128
- local red = KColor(1, 0, 0, alpha)
129
- local green = KColor(0, 1, 0, alpha)
130
-
131
- -- Go through each message.
132
- for i, msg in ipairs(messageArray) do
133
- local color = white
134
-
135
- local hasSuccess = string.match(msg, "Compilation successful.")
136
- if hasSuccess ~= nil then
137
- color = green
138
- end
139
-
140
- local hasErrors = string.match(msg, "Found [0-9]+ errors.")
141
- if hasErrors ~= nil then
142
- color = red
143
- end
144
-
145
- font:DrawStringScaledUTF8(
146
- msg,
147
- x,
148
- y + ((i - 1) * lineHeight),
149
- scale,
150
- scale,
151
- color,
152
- 0,
153
- true
154
- )
155
- end
156
- end
157
-
158
- function IsaacScriptWatcher:LoadSaveDat()
159
- -- Local variables
160
- local isaacFrameCount = Isaac.GetFrameCount()
161
-
162
- -- Read the "save.dat" file every third second, since file reads are expensive.
163
- if isaacFrameCount % 20 ~= 0 then
164
- return
165
- end
166
-
167
- -- Check to see if there a "save.dat" file for this save slot.
168
- if not Isaac.HasModData(IsaacScriptWatcher) then
169
- IsaacScriptWatcher:ClearSaveDat()
170
- return
171
- end
172
-
173
- -- The server will write JSON data for us to the "save#.dat" file in the mod subdirectory.
174
- if not pcall(IsaacScriptWatcher.Load) then
175
- -- Sometimes loading can fail if the file is currently being being written to, so give up for
176
- -- now and try again on the next interval.
177
- Isaac.DebugString(
178
- MOD_NAME
179
- .. " - Failed to load the TypeScript Watcher \"save.dat\" on frame: "
180
- .. tostring(isaacFrameCount)
181
- )
182
- return
183
- end
184
-
185
- if #saveData > 0 then
186
- local saveDatContents = saveData
187
- IsaacScriptWatcher:ClearSaveDat()
188
- IsaacScriptWatcher:LoadSuccessful(saveDatContents)
189
- end
190
- end
191
-
192
- function IsaacScriptWatcher:LoadSuccessful(saveDatContents)
193
- frameOfLastSuccessfulLoad = Isaac.GetFrameCount()
194
-
195
- for _, entry in ipairs(saveDatContents) do
196
- -- Entry is e.g. { type: "command", data: "luamod revelations" }
197
- if entry.type == "command" then
198
- if entry.data == "restart" then
199
- -- If we restart on the first frame that a run is loading, then the game can crash.
200
- restartFrame = Isaac.GetFrameCount() + 1
201
- else
202
- Isaac.DebugString(MOD_NAME .. " - Executing command: " .. entry.data)
203
- Isaac.ExecuteCommand(entry.data)
204
- end
205
- elseif entry.type == "msg" then
206
- Isaac.DebugString(MOD_NAME .. " - " .. entry.data)
207
- pushMessageArray(entry.data)
208
- end
209
- end
210
- end
211
-
212
- function IsaacScriptWatcher:ClearSaveDat()
213
- saveData = {}
214
- IsaacScriptWatcher:Save()
215
- end
216
-
217
- function IsaacScriptWatcher:Save()
218
- local saveDataJSON = json.encode(saveData)
219
- IsaacScriptWatcher:SaveData(saveDataJSON)
220
- end
221
-
222
- function IsaacScriptWatcher:Load()
223
- -- Read the "save#.dat" file into a string.
224
- local saveDataJSON = Isaac.LoadModData(IsaacScriptWatcher)
225
-
226
- -- Handle the case of a 0 byte file.
227
- if saveDataJSON == "" then
228
- saveDataJSON = "{}"
229
- end
230
-
231
- -- Convert a JSON string to a Lua table.
232
- saveData = json.decode(saveDataJSON)
233
- end
234
-
235
- function IsaacScriptWatcher:CheckInput()
236
- if game:IsPaused() then
237
- return
238
- end
239
-
240
- -- Ensure that this feature does not overlap with custom consoles by checking for the
241
- -- "AwaitingTextInput" global variable.
242
- if AwaitingTextInput then
243
- return
244
- end
245
-
246
- -- Manually show the log when the user presses the "I" key on the keyboard.
247
- if Input.IsButtonPressed(Keyboard.KEY_I, 0) then
248
- frameOfLastMsg = Isaac.GetFrameCount()
249
- end
250
- end
251
-
252
- function IsaacScriptWatcher:CheckRestart()
253
- if not RESTART_GAME_ON_RECOMPILATION then
254
- return
255
- end
256
-
257
- if restartFrame == 0 or restartFrame < Isaac.GetFrameCount() then
258
- return
259
- end
260
- restartFrame = 0
261
-
262
- Isaac.DebugString(MOD_NAME .. " - Restarting the run.")
263
- Isaac.ExecuteCommand("restart")
264
- end
265
-
266
- IsaacScriptWatcher:AddCallback(ModCallbacks.MC_POST_RENDER, IsaacScriptWatcher.PostRender)
267
-
268
- local initMessage = "IsaacScript Watcher initialized."
269
- Isaac.DebugString(initMessage)
270
- pushMessageArray(initMessage)
@@ -1,7 +0,0 @@
1
- <metadata>
2
- <name>IsaacScript Watcher</name>
3
- <directory>isaacscript-watcher</directory>
4
- <description />
5
- <version>1.0</version>
6
- <visibility />
7
- </metadata>
@@ -1,27 +0,0 @@
1
- <AnimatedActor>
2
- <Info CreatedBy="Unknown" CreatedOn="2/1/2017 6:09:20 AM" Version="2" Fps="30"/>
3
- <Content>
4
- <Spritesheets>
5
- <Spritesheet Path="logo.png" Id="0"/>
6
- </Spritesheets>
7
- <Layers>
8
- <Layer Name="Layer 0" Id="0" SpritesheetId="0"/>
9
- </Layers>
10
- <Nulls/>
11
- <Events/>
12
- </Content>
13
- <Animations DefaultAnimation="Default">
14
- <Animation Name="Default" FrameNum="1" Loop="true">
15
- <RootAnimation>
16
- <Frame XPosition="0" YPosition="0" XScale="100" YScale="100" Delay="1" Visible="true" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
17
- </RootAnimation>
18
- <LayerAnimations>
19
- <LayerAnimation LayerId="0" Visible="true">
20
- <Frame XPosition="0" YPosition="0" XPivot="0" YPivot="0" XCrop="0" YCrop="0" Width="44" Height="28" XScale="66" YScale="66" Delay="1" Visible="true" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
21
- </LayerAnimation>
22
- </LayerAnimations>
23
- <NullAnimations/>
24
- <Triggers/>
25
- </Animation>
26
- </Animations>
27
- </AnimatedActor>
package/lint.sh DELETED
@@ -1,38 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e # Exit on any errors
4
-
5
- # Get the directory of this script:
6
- # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
- DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
-
9
- SECONDS=0
10
-
11
- cd "$DIR"
12
-
13
- # Step 1 - Use Prettier to check formatting.
14
- npx prettier --check .
15
-
16
- # Step 2 - Use ESLint to lint the TypeScript.
17
- # Since all ESLint errors are set to warnings, we set max warnings to 0 so that warnings will fail
18
- # in CI.
19
- npx eslint --max-warnings 0 src
20
-
21
- # Step 3 - Spell check every file using cspell.
22
- # We use "--no-progress" and "--no-summary" because we want to only output errors.
23
- npx cspell --no-progress --no-summary
24
-
25
- # Step 4 - Check for unused imports.
26
- # The "--error" flag makes it return an error code of 1 if unused exports are found.
27
- npx ts-prune --error
28
-
29
- # Step 5 - Check for base file updates.
30
- bash "$DIR/check-file-updates.sh"
31
-
32
- # Step 6 - Check for orphaned words.
33
- bash "$DIR/check-orphaned-words.sh"
34
-
35
- # Step 7 - Check for gitignore updates from GitHub.
36
- bash "$DIR/check-gitignore.sh"
37
-
38
- echo "Successfully linted in $SECONDS seconds."
package/misc/logo.png DELETED
Binary file
Binary file
package/nuke.sh DELETED
@@ -1,18 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e # Exit on any errors
4
-
5
- # Get the directory of this script:
6
- # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
- DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
-
9
- PACKAGE_LOCK="$DIR/package-lock.json"
10
- rm -f "$PACKAGE_LOCK"
11
- echo "Successfully deleted: $PACKAGE_LOCK"
12
-
13
- NODE_MODULES="$DIR/node_modules"
14
- rm -rf "$NODE_MODULES"
15
- echo "Successfully deleted: $NODE_MODULES"
16
-
17
- npm install
18
- echo "Successfully reinstalled Node dependencies."
package/publish.sh DELETED
@@ -1,11 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e # Exit on any errors
4
-
5
- # Get the directory of this script:
6
- # https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
7
- DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
-
9
- cd "$DIR"
10
- pip install publish-npm --upgrade --quiet
11
- publish-npm "$@"
@@ -1,106 +0,0 @@
1
- import chalk from "chalk";
2
- import fs from "fs";
3
- import path from "path";
4
- import { HOME_DIR, PROJECT_NAME } from "./constants";
5
- import * as file from "./file";
6
- import { getInputYesNo } from "./prompt";
7
- import { error } from "./utils";
8
-
9
- const BASH_PROFILE_PATH = path.join(HOME_DIR, ".bash_profile");
10
-
11
- /**
12
- * By default, Git Bash for Windows uses MINGW64. This will not work correctly with the prompt
13
- * library. Try to detect this and warn the end-user.
14
- */
15
- export async function checkForWindowsTerminalBugs(
16
- verbose: boolean,
17
- ): Promise<void> {
18
- if (process.platform !== "win32") {
19
- return;
20
- }
21
-
22
- if (process.env["SHELL"] !== "C:\\Program Files\\Git\\usr\\bin\\bash.exe") {
23
- return;
24
- }
25
-
26
- await checkForWindowsBugColor(verbose);
27
- }
28
-
29
- async function checkForWindowsBugColor(verbose: boolean) {
30
- if (process.env["FORCE_COLOR"] === "true") {
31
- return;
32
- }
33
-
34
- console.error(
35
- chalk.red(
36
- `Error: It looks like you are using Git Bash for Windows (MINGW64) without the "${chalk.green(
37
- "FORCE_COLOR",
38
- )}" environment variable.`,
39
- ),
40
- );
41
- console.error(
42
- "This is necessary in order for colors to work properly in the terminal.",
43
- );
44
-
45
- const shouldFixColors = await getInputYesNo(
46
- "Do you want me to fix this for you?",
47
- );
48
- if (!shouldFixColors) {
49
- return;
50
- }
51
-
52
- applyFixesToBashProfile(verbose);
53
- }
54
-
55
- function applyFixesToBashProfile(verbose: boolean) {
56
- // Check to see if the Bash profile has data.
57
- let bashProfileContents: string;
58
- if (file.exists(BASH_PROFILE_PATH, verbose)) {
59
- bashProfileContents = file.read(BASH_PROFILE_PATH, verbose);
60
- } else {
61
- bashProfileContents = "";
62
- }
63
-
64
- const appendText = getBashProfileAppendText(bashProfileContents);
65
-
66
- try {
67
- fs.appendFileSync(BASH_PROFILE_PATH, appendText);
68
- } catch (err) {
69
- error(`Failed to append text to "${BASH_PROFILE_PATH}":`, err);
70
- }
71
-
72
- console.log(
73
- chalk.green("Complete!"),
74
- `The terminal fixes have been added to: ${chalk.green(BASH_PROFILE_PATH)}`,
75
- );
76
- console.log(
77
- chalk.red(
78
- "Please close and re-open your terminal, then run this program again.",
79
- ),
80
- );
81
- process.exit(0);
82
- }
83
-
84
- function getBashProfileAppendText(bashProfileContents: string) {
85
- let newText = "";
86
-
87
- if (
88
- bashProfileContents !== "" &&
89
- bashProfileContents[bashProfileContents.length - 1] !== "\n"
90
- ) {
91
- // If the Bash profile exists and has data, it should end in a newline. Add an extra newline if
92
- // this is not the case.
93
- newText += "\n";
94
- }
95
-
96
- if (bashProfileContents !== "") {
97
- // If the Bash profile exists and has data, add an extra newline between the existing stuff and
98
- // the new lines added by us.
99
- newText += "\n";
100
- }
101
-
102
- newText += `# Terminal fixes added by ${PROJECT_NAME}\n`;
103
- newText += "export FORCE_COLOR=true\n";
104
-
105
- return newText;
106
- }
@@ -1,41 +0,0 @@
1
- import path from "path";
2
- import { MOD_SOURCE_PATH } from "../../constants";
3
- import { execShell } from "../../exec";
4
- import * as file from "../../file";
5
- import { Config } from "../../types/Config";
6
- import { getModTargetDirectoryName } from "../../utils";
7
-
8
- export function copy(argv: Record<string, unknown>, config: Config): void {
9
- const verbose = argv["verbose"] === true;
10
-
11
- const modTargetDirectoryName = getModTargetDirectoryName(config);
12
- const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
13
-
14
- compileAndCopy(MOD_SOURCE_PATH, modTargetPath, verbose);
15
- }
16
-
17
- export function compileAndCopy(
18
- modSourcePath: string,
19
- modTargetPath: string,
20
- verbose: boolean,
21
- ): void {
22
- compile(verbose);
23
- copyMod(modSourcePath, modTargetPath, verbose);
24
- }
25
-
26
- function compile(verbose: boolean) {
27
- execShell("npx", ["tstl"], verbose);
28
- console.log("Mod compiled successfully.");
29
- }
30
-
31
- function copyMod(
32
- modSourcePath: string,
33
- modTargetPath: string,
34
- verbose: boolean,
35
- ) {
36
- if (file.exists(modTargetPath, verbose)) {
37
- file.deleteFileOrDirectory(modTargetPath, verbose);
38
- }
39
- file.copy(modSourcePath, modTargetPath, verbose);
40
- console.log("Mod copied successfully.");
41
- }
@@ -1,34 +0,0 @@
1
- import chalk from "chalk";
2
- import { CWD } from "../../constants";
3
- import * as file from "../../file";
4
- import { getInputYesNo } from "../../prompt";
5
- import { error } from "../../utils";
6
-
7
- export async function checkIfProjectPathExists(
8
- projectPath: string,
9
- yes: boolean,
10
- verbose: boolean,
11
- ): Promise<void> {
12
- if (projectPath === CWD || !file.exists(projectPath, verbose)) {
13
- return;
14
- }
15
-
16
- const fileType = file.isDir(projectPath, verbose) ? "directory" : "file";
17
-
18
- if (yes) {
19
- file.deleteFileOrDirectory(projectPath, verbose);
20
- console.log(`Deleted ${fileType}: ${chalk.green(projectPath)}`);
21
- return;
22
- }
23
-
24
- console.log(
25
- `A ${fileType} already exists with a name of: ${chalk.green(projectPath)}`,
26
- );
27
- const shouldDelete = await getInputYesNo("Do you want me to delete it?");
28
-
29
- if (!shouldDelete) {
30
- error("Ok then. Goodbye.");
31
- }
32
-
33
- file.deleteFileOrDirectory(projectPath, verbose);
34
- }
@@ -1,20 +0,0 @@
1
- import chalk from "chalk";
2
- import { CWD } from "../../constants";
3
- import * as file from "../../file";
4
- import { error } from "../../utils";
5
-
6
- export function checkModSubdirectory(
7
- projectPath: string,
8
- modsDirectory: string,
9
- ): void {
10
- if (file.isSubDirOf(CWD, modsDirectory)) {
11
- console.error(
12
- `Error: The project directory of "${chalk.green(
13
- projectPath,
14
- )}" is a subdirectory of "${chalk.green(modsDirectory)}".`,
15
- );
16
- error(
17
- 'You are supposed to have your project folder somewhere else on the system than the Isaac mods directory. (This is because we don\'t want to upload the ".git" folder or the TypeScript files to the Steam Workshop.) Exiting.',
18
- );
19
- }
20
- }
@@ -1,42 +0,0 @@
1
- import chalk from "chalk";
2
- import path from "path";
3
- import { PROJECT_NAME } from "../../constants";
4
- import * as file from "../../file";
5
- import { getInputYesNo } from "../../prompt";
6
- import { error } from "../../utils";
7
-
8
- export async function checkModTargetDirectory(
9
- modsDirectory: string,
10
- projectName: string,
11
- yes: boolean,
12
- verbose: boolean,
13
- ): Promise<void> {
14
- const modTargetPath = path.join(modsDirectory, projectName);
15
- if (!file.exists(modTargetPath, verbose)) {
16
- return;
17
- }
18
-
19
- const fileType = file.isDir(modTargetPath, verbose) ? "directory" : "file";
20
-
21
- if (yes) {
22
- file.deleteFileOrDirectory(modTargetPath, verbose);
23
- console.log(`Deleted ${fileType}: ${chalk.green(modTargetPath)}`);
24
- return;
25
- }
26
-
27
- console.log(
28
- `A ${fileType} already exists at at the mod path of: ${chalk.green(
29
- modTargetPath,
30
- )}`,
31
- );
32
- console.log(
33
- `${PROJECT_NAME} will need to sync your project folder with this directory.`,
34
- );
35
- const shouldDelete = await getInputYesNo("Do you want me to delete it?");
36
-
37
- if (!shouldDelete) {
38
- error("Ok then. Goodbye.");
39
- }
40
-
41
- file.deleteFileOrDirectory(modTargetPath, verbose);
42
- }