isaacscript 1.2.45 → 2.0.2
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-base.json +38 -0
- package/.cspell-check-unused.json +7 -0
- package/.cspell.json +51 -35
- package/.eslintrc.js +14 -10
- package/.gitattributes +3 -3
- package/.github/workflows/ci.yml +3 -4
- package/.prettierignore +5 -0
- package/.prettierrc.js +19 -5
- package/.vscode/extensions.json +2 -3
- package/.vscode/settings.json +26 -15
- package/README.md +3 -3
- package/build.sh +2 -2
- package/check-file-updates.sh +56 -0
- package/check-gitignore.sh +26 -0
- package/check-orphaned-words.sh +53 -0
- package/dist/package.json +6 -6
- package/dist/src/checkForWindowsTerminalBugs.js +8 -7
- package/dist/src/checkForWindowsTerminalBugs.js.map +1 -1
- package/dist/src/commands/init/createMod.js +13 -8
- package/dist/src/commands/init/createMod.js.map +1 -1
- package/dist/src/commands/init/getModsDir.js +4 -5
- package/dist/src/commands/init/getModsDir.js.map +1 -1
- package/dist/src/commands/init/getProjectPath.js +5 -5
- package/dist/src/commands/init/getProjectPath.js.map +1 -1
- package/dist/src/commands/init/git.js +2 -2
- package/dist/src/commands/init/git.js.map +1 -1
- package/dist/src/commands/init/promptSaveSlot.js +3 -4
- package/dist/src/commands/init/promptSaveSlot.js.map +1 -1
- package/dist/src/commands/init/promptVSCode.js +1 -2
- package/dist/src/commands/init/promptVSCode.js.map +1 -1
- package/dist/src/commands/monitor/copyWatcherMod.js +9 -11
- package/dist/src/commands/monitor/copyWatcherMod.js.map +1 -1
- package/dist/src/commands/monitor/monitor.js +3 -4
- package/dist/src/commands/monitor/monitor.js.map +1 -1
- package/dist/src/commands/monitor/notifyGame.js +3 -3
- package/dist/src/commands/monitor/notifyGame.js.map +1 -1
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +8 -8
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
- package/dist/src/exec.js +2 -3
- package/dist/src/exec.js.map +1 -1
- package/dist/src/file.js +16 -1
- package/dist/src/file.js.map +1 -1
- package/dist/src/prompt.js +5 -7
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/validateNodeVersion.js +4 -3
- package/dist/src/validateNodeVersion.js.map +1 -1
- package/eslint-debug.sh +8 -0
- package/file-templates/dynamic/README.md +2 -2
- package/file-templates/dynamic/main.ts +7 -5
- package/file-templates/dynamic/metadata.vdf +1 -1
- package/file-templates/dynamic/metadata.xml +3 -3
- package/file-templates/dynamic/package.json +1 -1
- package/file-templates/static/.cspell-check-unused.json +9 -0
- package/file-templates/static/.cspell.json.template +9 -0
- package/file-templates/static/.eslintrc.js +11 -10
- package/file-templates/static/.gitattributes +3 -3
- package/file-templates/static/.github/workflows/ci.yml +4 -5
- package/file-templates/static/.prettierignore +10 -1
- package/file-templates/static/.prettierrc.js +19 -5
- package/file-templates/static/.vscode/extensions.json +2 -3
- package/file-templates/static/.vscode/settings.json +26 -14
- package/file-templates/static/build.sh +2 -2
- package/file-templates/static/check-orphaned-words.sh +53 -0
- package/file-templates/static/lint.sh +17 -16
- package/file-templates/static/nuke.sh +1 -1
- package/file-templates/static/publish.sh +1 -1
- package/file-templates/static/run.sh +1 -1
- package/file-templates/static/src/bundleEntry.ts +4 -4
- package/file-templates/static/tsconfig.eslint.json +3 -3
- package/file-templates/static/tsconfig.json +8 -10
- package/file-templates/static/update.sh +1 -1
- package/file-templates/static-alt/.cspell-base.json +38 -0
- package/file-templates/static-alt/.cspell-check-unused-base.json +7 -0
- package/file-templates/static-alt/.prettierignore-base +5 -0
- package/file-templates/static-alt/.prettierrc-base.js +29 -0
- package/file-templates/static-alt/.vscode/extensions-typescript.json +9 -0
- package/file-templates/static-alt/.vscode/settings-typescript.json +63 -0
- package/isaacscript-watcher/README.md +3 -2
- package/isaacscript-watcher/main.lua +31 -41
- package/lint.sh +19 -16
- package/nuke.sh +1 -1
- package/package.json +6 -6
- package/publish.sh +1 -1
- package/src/checkForWindowsTerminalBugs.ts +8 -7
- package/src/commands/init/createMod.ts +14 -8
- package/src/commands/init/getModsDir.ts +4 -5
- package/src/commands/init/getProjectPath.ts +5 -5
- package/src/commands/init/git.ts +2 -2
- package/src/commands/init/promptSaveSlot.ts +3 -4
- package/src/commands/init/promptVSCode.ts +1 -2
- package/src/commands/monitor/copyWatcherMod.ts +9 -11
- package/src/commands/monitor/monitor.ts +3 -4
- package/src/commands/monitor/notifyGame.ts +3 -3
- package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +8 -8
- package/src/exec.ts +2 -3
- package/src/file.ts +25 -0
- package/src/prompt.ts +5 -7
- package/src/utils.ts +1 -1
- package/src/validateNodeVersion.ts +5 -4
- package/tsconfig.eslint.json +3 -3
- package/tsconfig.json +9 -11
- package/update.sh +1 -1
- package/file-templates/static/.cspell.json +0 -11
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// This is the configuration file for Prettier, the auto-formatter:
|
|
2
|
+
// https://prettier.io/docs/en/configuration.html
|
|
3
|
+
module.exports = {
|
|
4
|
+
// https://prettier.io/docs/en/options.html#trailing-commas
|
|
5
|
+
// The default is "es5" - Trailing commas where valid in ES5 (objects, arrays, etc.)
|
|
6
|
+
// However, always having trailing commas is objectively better. The Airbnb style guide agrees:
|
|
7
|
+
// https://github.com/airbnb/javascript#commas--dangling
|
|
8
|
+
// Prettier itself also acknowledges Nik Graf's blog in their official blog:
|
|
9
|
+
// https://prettier.io/blog/2020/03/21/2.0.0.html
|
|
10
|
+
// https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
|
|
11
|
+
// Prettier will change the default in the future:
|
|
12
|
+
// https://github.com/prettier/prettier/issues/9369
|
|
13
|
+
trailingComma: "all",
|
|
14
|
+
|
|
15
|
+
// We want to always use "lf" to be consistent with all platforms.
|
|
16
|
+
endOfLine: "lf",
|
|
17
|
+
|
|
18
|
+
// Allow proper formatting of JSONC files:
|
|
19
|
+
// https://github.com/prettier/prettier/issues/5708
|
|
20
|
+
overrides: [
|
|
21
|
+
{
|
|
22
|
+
files: ["**/.vscode/*.json", "**/tsconfig.json", "**/tsconfig.*.json"],
|
|
23
|
+
options: {
|
|
24
|
+
parser: "json5",
|
|
25
|
+
quoteProps: "preserve",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// These are Visual Studio Code extensions that are intended to be used with this particular
|
|
2
|
+
// repository: https://go.microsoft.com/fwlink/?LinkId=827846
|
|
3
|
+
{
|
|
4
|
+
"recommendations": [
|
|
5
|
+
"esbenp.prettier-vscode", // The TypeScript formatter
|
|
6
|
+
"dbaeumer.vscode-eslint", // The TypeScript linter
|
|
7
|
+
"streetsidesoftware.code-spell-checker", // A spell-checker extension based on cspell
|
|
8
|
+
],
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// These are Visual Studio Code settings that should apply to this particular repository.
|
|
2
|
+
{
|
|
3
|
+
// ----------------
|
|
4
|
+
// Vanilla settings
|
|
5
|
+
// ----------------
|
|
6
|
+
|
|
7
|
+
// This matches the Airbnb JavaScript style guide.
|
|
8
|
+
"editor.rulers": [100],
|
|
9
|
+
"editor.tabSize": 2,
|
|
10
|
+
|
|
11
|
+
// We want to always use "lf" to be consistent with all platforms.
|
|
12
|
+
"files.eol": "\n",
|
|
13
|
+
|
|
14
|
+
// Automatically removing all trailing whitespace when saving a file.
|
|
15
|
+
"files.trimTrailingWhitespace": true,
|
|
16
|
+
|
|
17
|
+
// Configure glob patterns for excluding files and folders in full text searches and quick open.
|
|
18
|
+
"search.exclude": {
|
|
19
|
+
"dist/**": true,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
// -----------------
|
|
23
|
+
// Language settings
|
|
24
|
+
// -----------------
|
|
25
|
+
|
|
26
|
+
// By default, VSCode will not automatically fill-in function arguments.
|
|
27
|
+
"javascript.suggest.completeFunctionCalls": true,
|
|
28
|
+
"typescript.suggest.completeFunctionCalls": true,
|
|
29
|
+
|
|
30
|
+
// Automatically run the formatter when certain files are saved.
|
|
31
|
+
"[javascript]": {
|
|
32
|
+
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
|
|
33
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
34
|
+
"editor.formatOnSave": true,
|
|
35
|
+
"editor.tabSize": 2,
|
|
36
|
+
},
|
|
37
|
+
"[typescript]": {
|
|
38
|
+
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
|
|
39
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
40
|
+
"editor.formatOnSave": true,
|
|
41
|
+
"editor.tabSize": 2,
|
|
42
|
+
},
|
|
43
|
+
"[json]": {
|
|
44
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
45
|
+
"editor.formatOnSave": true,
|
|
46
|
+
"editor.tabSize": 2,
|
|
47
|
+
},
|
|
48
|
+
"[jsonc]": {
|
|
49
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
50
|
+
"editor.formatOnSave": true,
|
|
51
|
+
"editor.tabSize": 2,
|
|
52
|
+
},
|
|
53
|
+
"[yaml]": {
|
|
54
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
55
|
+
"editor.formatOnSave": true,
|
|
56
|
+
"editor.tabSize": 2,
|
|
57
|
+
},
|
|
58
|
+
"[markdown]": {
|
|
59
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
60
|
+
"editor.formatOnSave": true,
|
|
61
|
+
"editor.tabSize": 2,
|
|
62
|
+
},
|
|
63
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
-- Includes
|
|
2
2
|
local json = require("json")
|
|
3
3
|
|
|
4
|
-
-- Register the mod
|
|
5
|
-
local IsaacScriptWatcher = RegisterMod("IsaacScript Watcher", 1)
|
|
6
|
-
|
|
7
4
|
-- Constants
|
|
8
5
|
local MOD_NAME = "isaacscript-watcher"
|
|
9
6
|
local RESTART_GAME_ON_RECOMPILATION = true
|
|
@@ -13,19 +10,21 @@ local SPRITE_BOTTOM_RIGHT_OFFSET = Vector(-35, -60)
|
|
|
13
10
|
-- (enough so that it does not overlap with a pocket active + 2 pocket items)
|
|
14
11
|
|
|
15
12
|
-- Mod variables
|
|
16
|
-
local saveData = {} -- An array of message objects
|
|
13
|
+
local saveData = {} -- An array of message objects.
|
|
17
14
|
local restartFrame = 0
|
|
18
15
|
local messageArray = {}
|
|
19
16
|
local frameOfLastMsg = 0
|
|
20
17
|
local frameOfLastSuccessfulLoad = 0
|
|
21
18
|
local game = Game()
|
|
22
19
|
local font = Font()
|
|
23
|
-
font:Load("font/pftempestasevencondensed.fnt") -- A vanilla font good for this kind of text
|
|
20
|
+
font:Load("font/pftempestasevencondensed.fnt") -- A vanilla font good for this kind of text.
|
|
24
21
|
local connected = false
|
|
25
22
|
local sprite = nil
|
|
26
23
|
|
|
24
|
+
local IsaacScriptWatcher = RegisterMod("IsaacScript Watcher", 1)
|
|
25
|
+
|
|
27
26
|
-- On mod initialization, nuke the "save#.dat" folder to get rid of old messages that might be left
|
|
28
|
-
-- there from IsaacScript
|
|
27
|
+
-- there from IsaacScript.
|
|
29
28
|
IsaacScriptWatcher:SaveData("")
|
|
30
29
|
|
|
31
30
|
local function pushMessageArray(msg)
|
|
@@ -33,15 +32,21 @@ local function pushMessageArray(msg)
|
|
|
33
32
|
|
|
34
33
|
messageArray[#messageArray + 1] = msg
|
|
35
34
|
if #messageArray > 10 then
|
|
36
|
-
-- We only want to show 10 messages at a time
|
|
37
|
-
-- Remove the first elemenent
|
|
35
|
+
-- We only want to show 10 messages at a time.
|
|
38
36
|
table.remove(messageArray, 1)
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
39
|
|
|
40
|
+
local function getScreenBottomRightPos()
|
|
41
|
+
local screenWidth = Isaac.GetScreenWidth();
|
|
42
|
+
local screenHeight = Isaac.GetScreenHeight();
|
|
43
|
+
|
|
44
|
+
return Vector(screenWidth, screenHeight)
|
|
45
|
+
end
|
|
46
|
+
|
|
42
47
|
-- ModCallbacks.MC_POST_RENDER (2)
|
|
43
48
|
function IsaacScriptWatcher:PostRender()
|
|
44
|
-
-- Don't do anything while
|
|
49
|
+
-- Don't do anything while fading in to a new run to prevent crashes.
|
|
45
50
|
if game:GetFrameCount() < 1 then
|
|
46
51
|
return
|
|
47
52
|
end
|
|
@@ -54,7 +59,7 @@ function IsaacScriptWatcher:PostRender()
|
|
|
54
59
|
end
|
|
55
60
|
|
|
56
61
|
function IsaacScriptWatcher:RenderSprite()
|
|
57
|
-
-- Determine if IsaacScript is connected or not
|
|
62
|
+
-- Determine if IsaacScript is connected or not.
|
|
58
63
|
local frameCount = Isaac.GetFrameCount()
|
|
59
64
|
connected = frameCount - frameOfLastSuccessfulLoad <= FRAMES_BEFORE_DISCONNECTED
|
|
60
65
|
|
|
@@ -73,13 +78,14 @@ function IsaacScriptWatcher:RenderSprite()
|
|
|
73
78
|
|
|
74
79
|
-- Render it
|
|
75
80
|
if sprite ~= nil then
|
|
76
|
-
local
|
|
81
|
+
local bottomRightPos = getScreenBottomRightPos()
|
|
82
|
+
local position = bottomRightPos + SPRITE_BOTTOM_RIGHT_OFFSET
|
|
77
83
|
sprite:RenderLayer(0, position)
|
|
78
84
|
end
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
function IsaacScriptWatcher:RenderText()
|
|
82
|
-
-- Don't draw IsaacScript text when custom consoles are open
|
|
88
|
+
-- Don't draw IsaacScript text when custom consoles are open.
|
|
83
89
|
if AwaitingTextInput then
|
|
84
90
|
return
|
|
85
91
|
end
|
|
@@ -104,7 +110,7 @@ function IsaacScriptWatcher:RenderText()
|
|
|
104
110
|
local scale = 1
|
|
105
111
|
local lineHeight = font:GetLineHeight() * scale
|
|
106
112
|
|
|
107
|
-
-- The text will slowly fade out
|
|
113
|
+
-- The text will slowly fade out.
|
|
108
114
|
local elapsedFrames = Isaac.GetFrameCount() - frameOfLastMsg
|
|
109
115
|
local alpha
|
|
110
116
|
if elapsedFrames <= FRAMES_BEFORE_TEXT_FADE then
|
|
@@ -122,7 +128,7 @@ function IsaacScriptWatcher:RenderText()
|
|
|
122
128
|
local red = KColor(1, 0, 0, alpha)
|
|
123
129
|
local green = KColor(0, 1, 0, alpha)
|
|
124
130
|
|
|
125
|
-
-- Go through each message
|
|
131
|
+
-- Go through each message.
|
|
126
132
|
for i, msg in ipairs(messageArray) do
|
|
127
133
|
local color = white
|
|
128
134
|
|
|
@@ -153,21 +159,21 @@ function IsaacScriptWatcher:LoadSaveDat()
|
|
|
153
159
|
-- Local variables
|
|
154
160
|
local isaacFrameCount = Isaac.GetFrameCount()
|
|
155
161
|
|
|
156
|
-
-- Read the "save.dat" file every third second, since file reads are expensive
|
|
162
|
+
-- Read the "save.dat" file every third second, since file reads are expensive.
|
|
157
163
|
if isaacFrameCount % 20 ~= 0 then
|
|
158
164
|
return
|
|
159
165
|
end
|
|
160
166
|
|
|
161
|
-
-- Check to see if there a "save.dat" file for this save slot
|
|
167
|
+
-- Check to see if there a "save.dat" file for this save slot.
|
|
162
168
|
if not Isaac.HasModData(IsaacScriptWatcher) then
|
|
163
169
|
IsaacScriptWatcher:ClearSaveDat()
|
|
164
170
|
return
|
|
165
171
|
end
|
|
166
172
|
|
|
167
|
-
-- The server will write JSON data for us to the "save#.dat" file in the mod subdirectory
|
|
173
|
+
-- The server will write JSON data for us to the "save#.dat" file in the mod subdirectory.
|
|
168
174
|
if not pcall(IsaacScriptWatcher.Load) then
|
|
169
|
-
-- Sometimes loading can fail if the file is currently being being written to,
|
|
170
|
-
--
|
|
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.
|
|
171
177
|
Isaac.DebugString(
|
|
172
178
|
MOD_NAME
|
|
173
179
|
.. " - Failed to load the TypeScript Watcher \"save.dat\" on frame: "
|
|
@@ -190,7 +196,7 @@ function IsaacScriptWatcher:LoadSuccessful(saveDatContents)
|
|
|
190
196
|
-- Entry is e.g. { type: "command", data: "luamod revelations" }
|
|
191
197
|
if entry.type == "command" then
|
|
192
198
|
if entry.data == "restart" then
|
|
193
|
-
-- If we restart on the first frame that a run is loading, then the game can crash
|
|
199
|
+
-- If we restart on the first frame that a run is loading, then the game can crash.
|
|
194
200
|
restartFrame = Isaac.GetFrameCount() + 1
|
|
195
201
|
else
|
|
196
202
|
Isaac.DebugString(MOD_NAME .. " - Executing command: " .. entry.data)
|
|
@@ -214,15 +220,15 @@ function IsaacScriptWatcher:Save()
|
|
|
214
220
|
end
|
|
215
221
|
|
|
216
222
|
function IsaacScriptWatcher:Load()
|
|
217
|
-
-- Read the "save#.dat" file into a string
|
|
223
|
+
-- Read the "save#.dat" file into a string.
|
|
218
224
|
local saveDataJSON = Isaac.LoadModData(IsaacScriptWatcher)
|
|
219
225
|
|
|
220
|
-
-- Handle the case of a 0 byte file
|
|
226
|
+
-- Handle the case of a 0 byte file.
|
|
221
227
|
if saveDataJSON == "" then
|
|
222
228
|
saveDataJSON = "{}"
|
|
223
229
|
end
|
|
224
230
|
|
|
225
|
-
-- Convert a JSON string to a Lua table
|
|
231
|
+
-- Convert a JSON string to a Lua table.
|
|
226
232
|
saveData = json.decode(saveDataJSON)
|
|
227
233
|
end
|
|
228
234
|
|
|
@@ -232,12 +238,12 @@ function IsaacScriptWatcher:CheckInput()
|
|
|
232
238
|
end
|
|
233
239
|
|
|
234
240
|
-- Ensure that this feature does not overlap with custom consoles by checking for the
|
|
235
|
-
-- "AwaitingTextInput" global variable
|
|
241
|
+
-- "AwaitingTextInput" global variable.
|
|
236
242
|
if AwaitingTextInput then
|
|
237
243
|
return
|
|
238
244
|
end
|
|
239
245
|
|
|
240
|
-
-- Manually show the log when the user presses the "I" key on the keyboard
|
|
246
|
+
-- Manually show the log when the user presses the "I" key on the keyboard.
|
|
241
247
|
if Input.IsButtonPressed(Keyboard.KEY_I, 0) then
|
|
242
248
|
frameOfLastMsg = Isaac.GetFrameCount()
|
|
243
249
|
end
|
|
@@ -257,22 +263,6 @@ function IsaacScriptWatcher:CheckRestart()
|
|
|
257
263
|
Isaac.ExecuteCommand("restart")
|
|
258
264
|
end
|
|
259
265
|
|
|
260
|
-
-- Kilburn's function (pinned in the Isaac Discord server)
|
|
261
|
-
-- (originally called "GetScreenSize()")
|
|
262
|
-
function IsaacScriptWatcher:GetBottomRightCorner()
|
|
263
|
-
local room = game:GetRoom()
|
|
264
|
-
local pos = (
|
|
265
|
-
room:WorldToScreenPosition(Vector.Zero)
|
|
266
|
-
- room:GetRenderScrollOffset()
|
|
267
|
-
- Game().ScreenShakeOffset
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
local rx = pos.X + 60 * 26 / 40
|
|
271
|
-
local ry = pos.Y + 140 * (26 / 40)
|
|
272
|
-
|
|
273
|
-
return Vector(rx * 2 + 13 * 26, ry * 2 + 7 * 26)
|
|
274
|
-
end
|
|
275
|
-
|
|
276
266
|
IsaacScriptWatcher:AddCallback(ModCallbacks.MC_POST_RENDER, IsaacScriptWatcher.PostRender)
|
|
277
267
|
|
|
278
268
|
local initMessage = "IsaacScript Watcher initialized."
|
package/lint.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
set -e # Exit on any errors
|
|
4
4
|
|
|
5
|
-
# Get the directory of this script
|
|
5
|
+
# Get the directory of this script:
|
|
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
|
|
|
@@ -10,26 +10,29 @@ SECONDS=0
|
|
|
10
10
|
|
|
11
11
|
cd "$DIR"
|
|
12
12
|
|
|
13
|
-
# Step 1 - Use Prettier to check formatting
|
|
14
|
-
npx prettier --check
|
|
13
|
+
# Step 1 - Use Prettier to check formatting.
|
|
14
|
+
npx prettier --check .
|
|
15
15
|
|
|
16
|
-
# Step 2 - Use ESLint to lint the TypeScript
|
|
17
|
-
# Since all ESLint errors are set to warnings,
|
|
18
|
-
#
|
|
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
19
|
npx eslint --max-warnings 0 src
|
|
20
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
|
|
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
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
|
|
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
27
|
npx ts-prune --error
|
|
28
28
|
|
|
29
|
-
# Step 5 - Check for
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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"
|
|
34
37
|
|
|
35
38
|
echo "Successfully linted in $SECONDS seconds."
|
package/nuke.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
set -e # Exit on any errors
|
|
4
4
|
|
|
5
|
-
# Get the directory of this script
|
|
5
|
+
# Get the directory of this script:
|
|
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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "A command line tool for managing Isaac mods written in TypeScript",
|
|
5
5
|
"homepage": "https://isaacscript.github.io/",
|
|
6
6
|
"bugs": {
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"isaacscript": "./dist/src/main.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@types/node": "^17.0.
|
|
19
|
+
"@types/node": "^17.0.33",
|
|
20
20
|
"chalk": "4.1.2",
|
|
21
21
|
"command-exists": "^1.2.9",
|
|
22
22
|
"dotenv": "^16.0.1",
|
|
23
23
|
"figlet": "^1.5.2",
|
|
24
24
|
"fs-extra": "^10.1.0",
|
|
25
|
-
"isaacscript-tsconfig": "^1.1.
|
|
25
|
+
"isaacscript-tsconfig": "^1.1.16",
|
|
26
26
|
"jsonc-parser": "^3.0.0",
|
|
27
27
|
"moment": "^2.29.3",
|
|
28
28
|
"npm-check-updates": "^12.5.11",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"typescript": "^4.6.4",
|
|
35
35
|
"typescript-to-lua": "^1.4.4",
|
|
36
36
|
"update-notifier": "^5.1.0",
|
|
37
|
-
"yaml": "^2.0
|
|
38
|
-
"yargs": "^17.
|
|
37
|
+
"yaml": "^2.1.0",
|
|
38
|
+
"yargs": "^17.5.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/command-exists": "^1.2.0",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"@types/source-map-support": "^0.5.4",
|
|
46
46
|
"@types/update-notifier": "^5.1.0",
|
|
47
47
|
"@types/yargs": "^17.0.10",
|
|
48
|
-
"isaacscript-lint": "^1.0.
|
|
48
|
+
"isaacscript-lint": "^1.0.140"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/publish.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
set -e # Exit on any errors
|
|
4
4
|
|
|
5
|
-
# Get the directory of this script
|
|
5
|
+
# Get the directory of this script:
|
|
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
|
|
|
@@ -8,9 +8,10 @@ import { error } from "./utils";
|
|
|
8
8
|
|
|
9
9
|
const BASH_PROFILE_PATH = path.join(HOME_DIR, ".bash_profile");
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
*/
|
|
14
15
|
export async function checkForWindowsTerminalBugs(
|
|
15
16
|
verbose: boolean,
|
|
16
17
|
): Promise<void> {
|
|
@@ -52,7 +53,7 @@ async function checkForWindowsBugColor(verbose: boolean) {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
function applyFixesToBashProfile(verbose: boolean) {
|
|
55
|
-
// Check to see if the Bash profile has data
|
|
56
|
+
// Check to see if the Bash profile has data.
|
|
56
57
|
let bashProfileContents: string;
|
|
57
58
|
if (file.exists(BASH_PROFILE_PATH, verbose)) {
|
|
58
59
|
bashProfileContents = file.read(BASH_PROFILE_PATH, verbose);
|
|
@@ -87,14 +88,14 @@ function getBashProfileAppendText(bashProfileContents: string) {
|
|
|
87
88
|
bashProfileContents !== "" &&
|
|
88
89
|
bashProfileContents[bashProfileContents.length - 1] !== "\n"
|
|
89
90
|
) {
|
|
90
|
-
// If the Bash profile exists and has data, it should end in a newline
|
|
91
|
-
//
|
|
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.
|
|
92
93
|
newText += "\n";
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
if (bashProfileContents !== "") {
|
|
96
97
|
// If the Bash profile exists and has data, add an extra newline between the existing stuff and
|
|
97
|
-
// the new lines added by us
|
|
98
|
+
// the new lines added by us.
|
|
98
99
|
newText += "\n";
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -52,7 +52,7 @@ export function createMod(
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function makeSubdirectories(projectPath: string, verbose: boolean) {
|
|
55
|
-
// The "src" directory is created during copying of static files
|
|
55
|
+
// The "src" directory is created during copying of static files.
|
|
56
56
|
for (const subdirectory of ["mod"]) {
|
|
57
57
|
const srcPath = path.join(projectPath, subdirectory);
|
|
58
58
|
file.makeDir(srcPath, verbose);
|
|
@@ -69,6 +69,12 @@ function copyStaticFiles(projectPath: string, verbose: boolean) {
|
|
|
69
69
|
file.copy(templateFilePath, destinationFilePath, verbose);
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
+
|
|
73
|
+
// Rename ".cspell.json.template" to ".cspell.json.template". (If it is kept as ".cspell.json",
|
|
74
|
+
// then local spell checking will fail.)
|
|
75
|
+
const cSpellConfigPath = path.join(projectPath, ".cspell.json.template");
|
|
76
|
+
const correctCSpellConfigPath = path.join(projectPath, ".cspell.json");
|
|
77
|
+
file.rename(cSpellConfigPath, correctCSpellConfigPath, verbose);
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
/** Copy files that need to have text replaced inside of them. */
|
|
@@ -103,7 +109,7 @@ function copyDynamicFiles(
|
|
|
103
109
|
const fileName = PACKAGE_JSON;
|
|
104
110
|
const templatePath = PACKAGE_JSON_TEMPLATE_PATH;
|
|
105
111
|
const template = file.read(templatePath, verbose);
|
|
106
|
-
const packageJSON = template.replace(/
|
|
112
|
+
const packageJSON = template.replace(/MOD-NAME-TO-REPLACE/g, projectName);
|
|
107
113
|
const destinationPath = path.join(projectPath, fileName);
|
|
108
114
|
file.write(destinationPath, packageJSON, verbose);
|
|
109
115
|
}
|
|
@@ -113,7 +119,7 @@ function copyDynamicFiles(
|
|
|
113
119
|
const fileName = README_MD;
|
|
114
120
|
const templatePath = README_MD_TEMPLATES_PATH;
|
|
115
121
|
const template = file.read(templatePath, verbose);
|
|
116
|
-
const readmeMD = template.replace(/
|
|
122
|
+
const readmeMD = template.replace(/MOD-NAME-TO-REPLACE/g, projectName);
|
|
117
123
|
const destinationPath = path.join(projectPath, fileName);
|
|
118
124
|
file.write(destinationPath, readmeMD, verbose);
|
|
119
125
|
}
|
|
@@ -123,7 +129,7 @@ function copyDynamicFiles(
|
|
|
123
129
|
const fileName = METADATA_XML;
|
|
124
130
|
const templatePath = METADATA_XML_TEMPLATE_PATH;
|
|
125
131
|
const template = file.read(templatePath, verbose);
|
|
126
|
-
const metadataXML = template.replace(/
|
|
132
|
+
const metadataXML = template.replace(/MOD-NAME-TO-REPLACE/g, projectName);
|
|
127
133
|
const modPath = path.join(projectPath, "mod");
|
|
128
134
|
const destinationPath = path.join(modPath, fileName);
|
|
129
135
|
file.write(destinationPath, metadataXML, verbose);
|
|
@@ -134,7 +140,7 @@ function copyDynamicFiles(
|
|
|
134
140
|
const fileName = METADATA_VDF;
|
|
135
141
|
const templatePath = METADATA_VDF_TEMPLATE_PATH;
|
|
136
142
|
const template = file.read(templatePath, verbose);
|
|
137
|
-
const metadataVDF = template.replace(/
|
|
143
|
+
const metadataVDF = template.replace(/MOD-TARGET-DIR/g, targetModDirectory);
|
|
138
144
|
const modPath = path.join(projectPath, "mod");
|
|
139
145
|
const destinationPath = path.join(modPath, fileName);
|
|
140
146
|
file.write(destinationPath, metadataVDF, verbose);
|
|
@@ -142,13 +148,13 @@ function copyDynamicFiles(
|
|
|
142
148
|
|
|
143
149
|
// "src/main.ts"
|
|
144
150
|
{
|
|
145
|
-
// Convert snake_case and kebab-case to camelCase
|
|
146
|
-
//
|
|
151
|
+
// Convert snake_case and kebab-case to camelCase. (Kebab-case in particular will make the
|
|
152
|
+
// example TypeScript file fail to compile.)
|
|
147
153
|
const srcPath = path.join(projectPath, "src");
|
|
148
154
|
const fileName = MAIN_TS;
|
|
149
155
|
const templatePath = MAIN_TS_TEMPLATE_PATH;
|
|
150
156
|
const template = file.read(templatePath, verbose);
|
|
151
|
-
const mainTS = template.replace(/
|
|
157
|
+
const mainTS = template.replace(/MOD-NAME-TO-REPLACE/g, projectName);
|
|
152
158
|
const destinationPath = path.join(srcPath, fileName);
|
|
153
159
|
file.write(destinationPath, mainTS, verbose);
|
|
154
160
|
}
|
|
@@ -17,7 +17,7 @@ const DEFAULT_MODS_PATH_WINDOWS = path.join(
|
|
|
17
17
|
MODS,
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/** This is a subdirectory of `$HOME`. */
|
|
21
21
|
const DEFAULT_MODS_PATH_LINUX = path.join(
|
|
22
22
|
HOME_DIR,
|
|
23
23
|
".local",
|
|
@@ -34,8 +34,8 @@ export async function getModsDir(
|
|
|
34
34
|
verbose: boolean,
|
|
35
35
|
): Promise<string> {
|
|
36
36
|
if (argv["modsDirectory"] !== undefined) {
|
|
37
|
-
// They specified the "--mods-directory" command-line flag,
|
|
38
|
-
//
|
|
37
|
+
// They specified the "--mods-directory" command-line flag, so there is no need to prompt the
|
|
38
|
+
// user for it.
|
|
39
39
|
return argv["modsDirectory"] as string;
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -97,12 +97,11 @@ function getDefaultModsPath(platform: string) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
default: {
|
|
100
|
-
error(
|
|
100
|
+
return error(
|
|
101
101
|
`There does not exist a default mod path for the platform of: ${chalk.green(
|
|
102
102
|
platform,
|
|
103
103
|
)}`,
|
|
104
104
|
);
|
|
105
|
-
return "";
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
}
|
|
@@ -27,23 +27,23 @@ export async function getProjectPath(
|
|
|
27
27
|
let projectPath: string;
|
|
28
28
|
let createNewDir: boolean;
|
|
29
29
|
if (useCurrentDir) {
|
|
30
|
-
// The "--use-current-dir" command-line flag was specified,
|
|
31
|
-
//
|
|
30
|
+
// The "--use-current-dir" command-line flag was specified, so there is no need to prompt the
|
|
31
|
+
// user.
|
|
32
32
|
projectName = CURRENT_DIRECTORY_NAME;
|
|
33
33
|
projectPath = CWD;
|
|
34
34
|
createNewDir = false;
|
|
35
35
|
} else if (projectName !== undefined) {
|
|
36
|
-
// The project name was specified on the command-line
|
|
36
|
+
// The project name was specified on the command-line.
|
|
37
37
|
projectPath = path.join(CWD, projectName);
|
|
38
38
|
createNewDir = true;
|
|
39
39
|
} else if (yes) {
|
|
40
40
|
// The "--yes" command-line flag was specified and the project name was not specified on the
|
|
41
|
-
// command-line, so default to using the current directory
|
|
41
|
+
// command-line, so default to using the current directory.
|
|
42
42
|
projectName = CURRENT_DIRECTORY_NAME;
|
|
43
43
|
projectPath = CWD;
|
|
44
44
|
createNewDir = false;
|
|
45
45
|
} else {
|
|
46
|
-
// The project name was not specified on the command-line, so prompt the user for it
|
|
46
|
+
// The project name was not specified on the command-line, so prompt the user for it.
|
|
47
47
|
[projectName, projectPath, createNewDir] = await getNewProjectName();
|
|
48
48
|
}
|
|
49
49
|
|
package/src/commands/init/git.ts
CHANGED
|
@@ -61,7 +61,7 @@ export async function promptGitHubRepoOrGitRemoteURL(
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// Assume that since they do not want to connect this project to the existing GitHub
|
|
64
|
-
// repository, they do not want to initialize a remote Git URL at all
|
|
64
|
+
// repository, they do not want to initialize a remote Git URL at all.
|
|
65
65
|
return undefined;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -83,7 +83,7 @@ export async function promptGitHubRepoOrGitRemoteURL(
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Assume that since they do not want to create a new GitHub repository, they do not want to
|
|
86
|
-
// initialize a remote Git URL at all
|
|
86
|
+
// initialize a remote Git URL at all.
|
|
87
87
|
return undefined;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -6,10 +6,9 @@ export async function promptSaveSlot(
|
|
|
6
6
|
yes: boolean,
|
|
7
7
|
): Promise<number> {
|
|
8
8
|
if (argv["saveSlot"] !== undefined) {
|
|
9
|
-
// They specified the "--save-slot" command-line flag,
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
return argv["saveSlot"] as number;
|
|
9
|
+
// They specified the "--save-slot" command-line flag, so there is no need to prompt the user
|
|
10
|
+
// for it.
|
|
11
|
+
return argv["saveSlot"] as number; // yargs converts this to a number
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
if (yes) {
|
|
@@ -10,8 +10,7 @@ export async function promptVSCode(
|
|
|
10
10
|
verbose: boolean,
|
|
11
11
|
): Promise<void> {
|
|
12
12
|
if (vscode) {
|
|
13
|
-
// They supplied the "--vscode" command-line flag,
|
|
14
|
-
// so there is no need to prompt the user
|
|
13
|
+
// They supplied the "--vscode" command-line flag, so there is no need to prompt the user.
|
|
15
14
|
openVSCode(projectPath, VSCodeCommand, verbose);
|
|
16
15
|
return;
|
|
17
16
|
}
|