isaacscript 1.2.29 → 1.2.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.
Files changed (74) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/checkForWindowsTerminalBugs.js +7 -7
  3. package/dist/src/checkForWindowsTerminalBugs.js.map +1 -1
  4. package/dist/src/commands/copy/copy.js +1 -1
  5. package/dist/src/commands/copy/copy.js.map +1 -1
  6. package/dist/src/commands/init/checkIfProjectPathExists.js +2 -2
  7. package/dist/src/commands/init/checkIfProjectPathExists.js.map +1 -1
  8. package/dist/src/commands/init/checkModTargetDirectory.js +2 -2
  9. package/dist/src/commands/init/checkModTargetDirectory.js.map +1 -1
  10. package/dist/src/commands/init/createMod.js +8 -8
  11. package/dist/src/commands/init/createMod.js.map +1 -1
  12. package/dist/src/commands/init/getModsDir.js +5 -4
  13. package/dist/src/commands/init/getModsDir.js.map +1 -1
  14. package/dist/src/commands/init/getProjectPath.js +7 -10
  15. package/dist/src/commands/init/getProjectPath.js.map +1 -1
  16. package/dist/src/commands/init/git.js +6 -6
  17. package/dist/src/commands/init/git.js.map +1 -1
  18. package/dist/src/commands/init/init.js +1 -1
  19. package/dist/src/commands/init/init.js.map +1 -1
  20. package/dist/src/commands/init/installVSCodeExtensions.js +4 -4
  21. package/dist/src/commands/init/installVSCodeExtensions.js.map +1 -1
  22. package/dist/src/commands/monitor/copyWatcherMod.js +3 -3
  23. package/dist/src/commands/monitor/copyWatcherMod.js.map +1 -1
  24. package/dist/src/commands/monitor/getTSConfigInclude.js +2 -2
  25. package/dist/src/commands/monitor/getTSConfigInclude.js.map +1 -1
  26. package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +2 -2
  27. package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +1 -1
  28. package/dist/src/commands/monitor/monitor.js +2 -2
  29. package/dist/src/commands/monitor/monitor.js.map +1 -1
  30. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +24 -18
  31. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
  32. package/dist/src/commands/monitor/spawnSaveDatWriter.js +1 -1
  33. package/dist/src/commands/monitor/spawnSaveDatWriter.js.map +1 -1
  34. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js +2 -2
  35. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +1 -1
  36. package/dist/src/commands/publish/publish.js +16 -16
  37. package/dist/src/commands/publish/publish.js.map +1 -1
  38. package/dist/src/configFile.js +5 -5
  39. package/dist/src/configFile.js.map +1 -1
  40. package/dist/src/exec.js +2 -2
  41. package/dist/src/exec.js.map +1 -1
  42. package/dist/src/file.js +37 -7
  43. package/dist/src/file.js.map +1 -1
  44. package/dist/src/main.js +5 -4
  45. package/dist/src/main.js.map +1 -1
  46. package/dist/src/utils.js +7 -1
  47. package/dist/src/utils.js.map +1 -1
  48. package/dist/src/validateInIsaacScriptProject.js +3 -2
  49. package/dist/src/validateInIsaacScriptProject.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/checkForWindowsTerminalBugs.ts +9 -7
  52. package/src/commands/copy/copy.ts +1 -1
  53. package/src/commands/init/checkIfProjectPathExists.ts +2 -2
  54. package/src/commands/init/checkModTargetDirectory.ts +2 -2
  55. package/src/commands/init/createMod.ts +8 -8
  56. package/src/commands/init/getModsDir.ts +7 -3
  57. package/src/commands/init/getProjectPath.ts +10 -11
  58. package/src/commands/init/git.ts +6 -6
  59. package/src/commands/init/init.ts +1 -1
  60. package/src/commands/init/installVSCodeExtensions.ts +4 -4
  61. package/src/commands/monitor/copyWatcherMod.ts +3 -3
  62. package/src/commands/monitor/getTSConfigInclude.ts +2 -2
  63. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +2 -2
  64. package/src/commands/monitor/monitor.ts +2 -2
  65. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +28 -20
  66. package/src/commands/monitor/spawnSaveDatWriter.ts +1 -1
  67. package/src/commands/monitor/touchWatcherSaveDatFiles.ts +2 -2
  68. package/src/commands/publish/publish.ts +16 -16
  69. package/src/configFile.ts +5 -5
  70. package/src/exec.ts +2 -4
  71. package/src/file.ts +51 -7
  72. package/src/main.ts +5 -4
  73. package/src/utils.ts +8 -0
  74. package/src/validateInIsaacScriptProject.ts +5 -2
@@ -109,7 +109,7 @@ function startPublish(
109
109
  updateDeps(verbose);
110
110
 
111
111
  let version =
112
- setVersion === undefined ? getVersionFromPackageJSON() : setVersion;
112
+ setVersion === undefined ? getVersionFromPackageJSON(verbose) : setVersion;
113
113
  if (!skipVersionIncrement && setVersion === undefined) {
114
114
  version = bumpVersionInPackageJSON(version, verbose);
115
115
  } else if (setVersion !== undefined) {
@@ -134,7 +134,7 @@ function startPublish(
134
134
  }
135
135
 
136
136
  function updateDeps(verbose: boolean) {
137
- if (!file.exists(UPDATE_SCRIPT_NAME)) {
137
+ if (!file.exists(UPDATE_SCRIPT_NAME, verbose)) {
138
138
  error(
139
139
  `The "${UPDATE_SCRIPT_NAME}" script does not exist in the current working directory.`,
140
140
  );
@@ -143,8 +143,8 @@ function updateDeps(verbose: boolean) {
143
143
  execShell("bash", [UPDATE_SCRIPT_NAME], verbose);
144
144
  }
145
145
 
146
- function getVersionFromPackageJSON() {
147
- if (!file.exists(PACKAGE_JSON_PATH)) {
146
+ function getVersionFromPackageJSON(verbose: boolean) {
147
+ if (!file.exists(PACKAGE_JSON_PATH, verbose)) {
148
148
  error(
149
149
  chalk.red(
150
150
  `A "${PACKAGE_JSON_PATH}" was not found in the current directory.`,
@@ -152,7 +152,7 @@ function getVersionFromPackageJSON() {
152
152
  );
153
153
  }
154
154
 
155
- const packageJSONRaw = file.read(PACKAGE_JSON_PATH);
155
+ const packageJSONRaw = file.read(PACKAGE_JSON_PATH, verbose);
156
156
  let packageJSON: Record<string, unknown>;
157
157
  try {
158
158
  packageJSON = JSON.parse(packageJSONRaw) as Record<string, unknown>;
@@ -204,7 +204,7 @@ function bumpVersionInPackageJSON(version: string, verbose: boolean): string {
204
204
  const incrementedPatchVersion = patchVersion + 1;
205
205
  const incrementedVersion = `${versionPrefix}${incrementedPatchVersion}`;
206
206
 
207
- const packageJSON = file.read(PACKAGE_JSON_PATH);
207
+ const packageJSON = file.read(PACKAGE_JSON_PATH, verbose);
208
208
  const newPackageJSON = packageJSON.replace(
209
209
  /"version": ".+",/,
210
210
  `"version": "${incrementedVersion}",`,
@@ -219,7 +219,7 @@ function bumpVersionInPackageJSON(version: string, verbose: boolean): string {
219
219
  }
220
220
 
221
221
  function writeVersionInPackageJSON(version: string, verbose: boolean) {
222
- const packageJSON = file.read(PACKAGE_JSON_PATH);
222
+ const packageJSON = file.read(PACKAGE_JSON_PATH, verbose);
223
223
  const newPackageJSON = packageJSON.replace(
224
224
  /"version": ".+",/,
225
225
  `"version": "${version}",`,
@@ -230,14 +230,14 @@ function writeVersionInPackageJSON(version: string, verbose: boolean) {
230
230
  }
231
231
 
232
232
  function writeVersionToConstantsTS(version: string, verbose: boolean) {
233
- if (!file.exists(CONSTANTS_TS_PATH)) {
233
+ if (!file.exists(CONSTANTS_TS_PATH, verbose)) {
234
234
  console.log(
235
235
  'Skipping writing the version to "constants.ts" since it was not found.',
236
236
  );
237
237
  return;
238
238
  }
239
239
 
240
- const constantsTS = file.read(CONSTANTS_TS_PATH);
240
+ const constantsTS = file.read(CONSTANTS_TS_PATH, verbose);
241
241
  const newConstantsTS = constantsTS.replace(
242
242
  /const VERSION = ".+"/,
243
243
  `const VERSION = "${version}"`,
@@ -248,7 +248,7 @@ function writeVersionToConstantsTS(version: string, verbose: boolean) {
248
248
  }
249
249
 
250
250
  function writeVersionToMetadataXML(version: string, verbose: boolean) {
251
- const metadataXML = file.read(METADATA_XML_PATH);
251
+ const metadataXML = file.read(METADATA_XML_PATH, verbose);
252
252
  const newMetadataXML = metadataXML.replace(
253
253
  /<version>.+<\/version>/,
254
254
  `<version>${version}</version>`,
@@ -265,7 +265,7 @@ function writeVersionToVersionTXT(version: string, verbose: boolean) {
265
265
  }
266
266
 
267
267
  function runReleaseScriptPreCopy(verbose: boolean) {
268
- if (!file.exists(PUBLISH_PRE_COPY_PY_PATH)) {
268
+ if (!file.exists(PUBLISH_PRE_COPY_PY_PATH, verbose)) {
269
269
  return;
270
270
  }
271
271
 
@@ -278,7 +278,7 @@ function runReleaseScriptPreCopy(verbose: boolean) {
278
278
  }
279
279
 
280
280
  function runReleaseScriptPostCopy(verbose: boolean) {
281
- if (!file.exists(PUBLISH_POST_COPY_PY_PATH)) {
281
+ if (!file.exists(PUBLISH_POST_COPY_PY_PATH, verbose)) {
282
282
  return;
283
283
  }
284
284
 
@@ -292,11 +292,11 @@ function runReleaseScriptPostCopy(verbose: boolean) {
292
292
 
293
293
  function purgeRoomXMLs(modTargetPath: string, verbose: boolean) {
294
294
  const roomsPath = path.join(modTargetPath, "resources", "rooms");
295
- if (!file.exists(roomsPath) || !file.isDir(roomsPath)) {
295
+ if (!file.exists(roomsPath, verbose) || !file.isDir(roomsPath, verbose)) {
296
296
  return;
297
297
  }
298
298
 
299
- const roomFileList = file.getDirList(roomsPath);
299
+ const roomFileList = file.getDirList(roomsPath, verbose);
300
300
  roomFileList.forEach((fileName: string) => {
301
301
  if (path.extname(fileName) === ".xml") {
302
302
  const roomFilePath = path.join(roomsPath, fileName);
@@ -327,7 +327,7 @@ function runSteamCmd(
327
327
  steamCmdPath: string,
328
328
  verbose: boolean,
329
329
  ) {
330
- if (!file.exists(steamCmdPath)) {
330
+ if (!file.exists(steamCmdPath, verbose)) {
331
331
  error(
332
332
  chalk.red(
333
333
  `The path provided for "steamCmdPath" is "${steamCmdPath}", but that does not exist.`,
@@ -336,7 +336,7 @@ function runSteamCmd(
336
336
  }
337
337
 
338
338
  const metadataVDFPath = path.join(modTargetPath, "metadata.vdf");
339
- if (!file.exists(metadataVDFPath)) {
339
+ if (!file.exists(metadataVDFPath, verbose)) {
340
340
  console.error(
341
341
  chalk.red(
342
342
  `A "metadata.vdf" file was not found in your mod directory. You must create this file in order for "steamcmd.exe" to work. Please see the ${PROJECT_NAME} docs:`,
package/src/configFile.ts CHANGED
@@ -12,13 +12,13 @@ export async function get(argv: Record<string, unknown>): Promise<Config> {
12
12
  const verbose = argv.verbose === true;
13
13
  const yes = argv.yes === true;
14
14
 
15
- const existingConfig = readExistingConfig();
15
+ const existingConfig = readExistingConfig(verbose);
16
16
  if (existingConfig !== undefined) {
17
17
  return existingConfig;
18
18
  }
19
19
 
20
20
  // No config file exists, so prompt the user for some information and create one
21
- const modsDirectory = await getModsDir(argv);
21
+ const modsDirectory = await getModsDir(argv, verbose);
22
22
  const saveSlot = await promptSaveSlot(argv, yes);
23
23
  const config = createObject(modsDirectory, saveSlot);
24
24
  createFile(CWD, config, verbose);
@@ -26,12 +26,12 @@ export async function get(argv: Record<string, unknown>): Promise<Config> {
26
26
  return config;
27
27
  }
28
28
 
29
- function readExistingConfig(): Config | undefined {
30
- if (!file.exists(CONFIG_FILE_PATH)) {
29
+ function readExistingConfig(verbose: boolean): Config | undefined {
30
+ if (!file.exists(CONFIG_FILE_PATH, verbose)) {
31
31
  return undefined;
32
32
  }
33
33
 
34
- const configRaw = file.read(CONFIG_FILE_PATH);
34
+ const configRaw = file.read(CONFIG_FILE_PATH, verbose);
35
35
  let config: Config;
36
36
  try {
37
37
  config = JSONC.parse(configRaw) as Config;
package/src/exec.ts CHANGED
@@ -3,7 +3,7 @@ import { execSync, spawnSync, SpawnSyncReturns } from "child_process";
3
3
  import { CWD } from "./constants";
4
4
  import { error } from "./utils";
5
5
 
6
- export function execExe(path: string, verbose = false, cwd = CWD): string {
6
+ export function execExe(path: string, verbose: boolean, cwd = CWD): string {
7
7
  if (verbose) {
8
8
  console.log(`Executing binary: ${path}`);
9
9
  }
@@ -103,9 +103,7 @@ export function execShell(
103
103
 
104
104
  const exitStatus = spawnSyncReturns.status;
105
105
  if (exitStatus === null) {
106
- error(
107
- `Failed to get the return status of th command: ${commandDescription}`,
108
- );
106
+ error(`Failed to get the return status of command: ${commandDescription}`);
109
107
  }
110
108
 
111
109
  const stdout = spawnSyncReturns.output.join("\n").trim();
package/src/file.ts CHANGED
@@ -51,7 +51,11 @@ export function deleteFileOrDirectory(
51
51
  }
52
52
  }
53
53
 
54
- export function exists(filePath: string): boolean {
54
+ export function exists(filePath: string, verbose: boolean): boolean {
55
+ if (verbose) {
56
+ console.log(`Checking to see if the following path exists: ${filePath}`);
57
+ }
58
+
55
59
  let pathExists: boolean;
56
60
  try {
57
61
  pathExists = fs.existsSync(filePath);
@@ -59,10 +63,18 @@ export function exists(filePath: string): boolean {
59
63
  error(`Failed to check to see if "${chalk.green(filePath)}" exists:`, err);
60
64
  }
61
65
 
66
+ if (verbose) {
67
+ console.log(`Path exists: ${pathExists}`);
68
+ }
69
+
62
70
  return pathExists;
63
71
  }
64
72
 
65
- export function getDirList(dirPath: string): string[] {
73
+ export function getDirList(dirPath: string, verbose: boolean): string[] {
74
+ if (verbose) {
75
+ console.log(`Getting a directory list from: ${dirPath}`);
76
+ }
77
+
66
78
  let fileList: string[];
67
79
  try {
68
80
  fileList = fs.readdirSync(dirPath);
@@ -73,10 +85,18 @@ export function getDirList(dirPath: string): string[] {
73
85
  );
74
86
  }
75
87
 
88
+ if (verbose) {
89
+ console.log(`Got a directory list from: ${dirPath}`);
90
+ }
91
+
76
92
  return fileList;
77
93
  }
78
94
 
79
- function getFileStats(filePath: string): fs.Stats {
95
+ function getFileStats(filePath: string, verbose: boolean): fs.Stats {
96
+ if (verbose) {
97
+ console.log(`Getting file stats from: ${filePath}`);
98
+ }
99
+
80
100
  let fileStats: fs.Stats;
81
101
  try {
82
102
  fileStats = fs.statSync(filePath);
@@ -84,11 +104,15 @@ function getFileStats(filePath: string): fs.Stats {
84
104
  error(`Failed to get the file stats for "${chalk.green(filePath)}":`, err);
85
105
  }
86
106
 
107
+ if (verbose) {
108
+ console.log(`Got file stats from: ${filePath}`);
109
+ }
110
+
87
111
  return fileStats;
88
112
  }
89
113
 
90
- export function isDir(filePath: string): boolean {
91
- const fileStats = getFileStats(filePath);
114
+ export function isDir(filePath: string, verbose: boolean): boolean {
115
+ const fileStats = getFileStats(filePath, verbose);
92
116
  return fileStats.isDirectory();
93
117
  }
94
118
 
@@ -117,7 +141,11 @@ export function makeDir(dirPath: string, verbose: boolean): void {
117
141
  }
118
142
  }
119
143
 
120
- export function read(filePath: string): string {
144
+ export function read(filePath: string, verbose: boolean): string {
145
+ if (verbose) {
146
+ console.log(`Reading a file: ${filePath}`);
147
+ }
148
+
121
149
  let fileContents: string;
122
150
  try {
123
151
  fileContents = fs.readFileSync(filePath, "utf8");
@@ -125,6 +153,10 @@ export function read(filePath: string): string {
125
153
  error(`Failed to read the "${chalk.green(filePath)}" file:`, err);
126
154
  }
127
155
 
156
+ if (verbose) {
157
+ console.log(`Read a file: ${filePath}`);
158
+ }
159
+
128
160
  return fileContents;
129
161
  }
130
162
 
@@ -161,6 +193,18 @@ export function write(filePath: string, data: string, verbose: boolean): void {
161
193
  }
162
194
  }
163
195
 
164
- export function writeTry(filePath: string, data: string): void {
196
+ export function writeTry(
197
+ filePath: string,
198
+ data: string,
199
+ verbose: boolean,
200
+ ): void {
201
+ if (verbose) {
202
+ console.log(`Writing data to: ${filePath}`);
203
+ }
204
+
165
205
  fs.writeFileSync(filePath, data);
206
+
207
+ if (verbose) {
208
+ console.log(`Wrote data to: ${filePath}`);
209
+ }
166
210
  }
package/src/main.ts CHANGED
@@ -36,6 +36,7 @@ async function main(): Promise<void> {
36
36
 
37
37
  // Get command line arguments
38
38
  const argv = parseArgs();
39
+ const verbose = argv.verbose === true;
39
40
 
40
41
  printBanner();
41
42
 
@@ -43,9 +44,9 @@ async function main(): Promise<void> {
43
44
  updateNotifier({ pkg }).notify();
44
45
 
45
46
  // Pre-flight checks
46
- await checkForWindowsTerminalBugs();
47
+ await checkForWindowsTerminalBugs(verbose);
47
48
 
48
- await handleCommands(argv);
49
+ await handleCommands(argv, verbose);
49
50
  }
50
51
 
51
52
  function loadEnvironmentVariables() {
@@ -62,7 +63,7 @@ function printBanner() {
62
63
  console.log();
63
64
  }
64
65
 
65
- async function handleCommands(argv: Record<string, unknown>) {
66
+ async function handleCommands(argv: Record<string, unknown>, verbose: boolean) {
66
67
  const positionalArgs = argv._ as string[];
67
68
  let command: Command;
68
69
  if (positionalArgs.length > 0) {
@@ -73,7 +74,7 @@ async function handleCommands(argv: Record<string, unknown>) {
73
74
 
74
75
  let config = new Config();
75
76
  if (command !== "init") {
76
- validateInIsaacScriptProject();
77
+ validateInIsaacScriptProject(verbose);
77
78
  config = await configFile.get(argv);
78
79
  }
79
80
 
package/src/utils.ts CHANGED
@@ -2,6 +2,10 @@ import moment from "moment";
2
2
  import { CURRENT_DIRECTORY_NAME } from "./constants";
3
3
  import { Config } from "./types/Config";
4
4
 
5
+ /** From: https://github.com/expandjs/expandjs/blob/master/lib/kebabCaseRegex.js */
6
+ const KEBAB_CASE_REGEX =
7
+ /^([a-z](?![\d])|[\d](?![a-z]))+(-?([a-z](?![\d])|[\d](?![a-z])))*$|^$/;
8
+
5
9
  export const ensureAllCases = (obj: never): never => obj;
6
10
 
7
11
  export function error(...args: unknown[]): never {
@@ -24,6 +28,10 @@ export function hasWhiteSpace(s: string): boolean {
24
28
  return /\s/g.test(s);
25
29
  }
26
30
 
31
+ export function isKebabCase(s: string): boolean {
32
+ return KEBAB_CASE_REGEX.test(s);
33
+ }
34
+
27
35
  /**
28
36
  * parseIntSafe is a more reliable version of parseInt. By default, "parseInt('1a')" will return
29
37
  * "1", which is unexpected. This returns either an integer or NaN.
@@ -4,11 +4,14 @@ import { CWD, PROJECT_NAME } from "./constants";
4
4
  import * as file from "./file";
5
5
 
6
6
  // Validate that we are in a directory that looks like an IsaacScript project
7
- export function validateInIsaacScriptProject(): void {
7
+ export function validateInIsaacScriptProject(verbose: boolean): void {
8
8
  const subdirectoriesToCheck = ["src", "mod", "node_modules"];
9
9
  for (const subdirectoryName of subdirectoriesToCheck) {
10
10
  const subdirectoryPath = path.join(CWD, subdirectoryName);
11
- if (!file.exists(subdirectoryPath) || !file.isDir(subdirectoryPath)) {
11
+ if (
12
+ !file.exists(subdirectoryPath, verbose) ||
13
+ !file.isDir(subdirectoryPath, verbose)
14
+ ) {
12
15
  errorNotExists(subdirectoryPath);
13
16
  }
14
17
  }