isaacscript 1.2.30 → 1.2.31

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 (68) 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 +5 -5
  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/monitor.js +2 -2
  27. package/dist/src/commands/monitor/monitor.js.map +1 -1
  28. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +13 -12
  29. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
  30. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js +2 -2
  31. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +1 -1
  32. package/dist/src/commands/publish/publish.js +16 -16
  33. package/dist/src/commands/publish/publish.js.map +1 -1
  34. package/dist/src/configFile.js +5 -5
  35. package/dist/src/configFile.js.map +1 -1
  36. package/dist/src/exec.js +2 -2
  37. package/dist/src/exec.js.map +1 -1
  38. package/dist/src/file.js +37 -7
  39. package/dist/src/file.js.map +1 -1
  40. package/dist/src/main.js +5 -4
  41. package/dist/src/main.js.map +1 -1
  42. package/dist/src/utils.js +7 -1
  43. package/dist/src/utils.js.map +1 -1
  44. package/dist/src/validateInIsaacScriptProject.js +3 -2
  45. package/dist/src/validateInIsaacScriptProject.js.map +1 -1
  46. package/package.json +2 -2
  47. package/src/checkForWindowsTerminalBugs.ts +9 -7
  48. package/src/commands/copy/copy.ts +1 -1
  49. package/src/commands/init/checkIfProjectPathExists.ts +2 -2
  50. package/src/commands/init/checkModTargetDirectory.ts +2 -2
  51. package/src/commands/init/createMod.ts +8 -8
  52. package/src/commands/init/getModsDir.ts +7 -3
  53. package/src/commands/init/getProjectPath.ts +10 -11
  54. package/src/commands/init/git.ts +5 -5
  55. package/src/commands/init/init.ts +1 -1
  56. package/src/commands/init/installVSCodeExtensions.ts +4 -4
  57. package/src/commands/monitor/copyWatcherMod.ts +3 -3
  58. package/src/commands/monitor/getTSConfigInclude.ts +2 -2
  59. package/src/commands/monitor/monitor.ts +2 -2
  60. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +14 -12
  61. package/src/commands/monitor/touchWatcherSaveDatFiles.ts +2 -2
  62. package/src/commands/publish/publish.ts +16 -16
  63. package/src/configFile.ts +5 -5
  64. package/src/exec.ts +2 -4
  65. package/src/file.ts +51 -7
  66. package/src/main.ts +5 -4
  67. package/src/utils.ts +8 -0
  68. package/src/validateInIsaacScriptProject.ts +5 -2
@@ -61,11 +61,11 @@ function makeSubdirectories(projectPath: string, verbose: boolean) {
61
61
 
62
62
  /** Copy static files, like ".eslintrc.js", "tsconfig.json", etc. */
63
63
  function copyStaticFiles(projectPath: string, verbose: boolean) {
64
- const staticFileList = file.getDirList(TEMPLATES_STATIC_DIR);
64
+ const staticFileList = file.getDirList(TEMPLATES_STATIC_DIR, verbose);
65
65
  staticFileList.forEach((fileName: string) => {
66
66
  const templateFilePath = path.join(TEMPLATES_STATIC_DIR, fileName);
67
67
  const destinationFilePath = path.join(projectPath, fileName);
68
- if (!file.exists(destinationFilePath)) {
68
+ if (!file.exists(destinationFilePath, verbose)) {
69
69
  file.copy(templateFilePath, destinationFilePath, verbose);
70
70
  }
71
71
  });
@@ -82,7 +82,7 @@ function copyDynamicFiles(
82
82
  {
83
83
  const fileName = GITIGNORE;
84
84
  const templatePath = GITIGNORE_TEMPLATE_PATH;
85
- const template = file.read(templatePath);
85
+ const template = file.read(templatePath, verbose);
86
86
 
87
87
  // Prepend a header with the project name
88
88
  let separatorLine = "# ";
@@ -102,7 +102,7 @@ function copyDynamicFiles(
102
102
  // Modify and copy the file
103
103
  const fileName = PACKAGE_JSON;
104
104
  const templatePath = PACKAGE_JSON_TEMPLATE_PATH;
105
- const template = file.read(templatePath);
105
+ const template = file.read(templatePath, verbose);
106
106
  const packageJSON = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
107
107
  const destinationPath = path.join(projectPath, fileName);
108
108
  file.write(destinationPath, packageJSON, verbose);
@@ -112,7 +112,7 @@ function copyDynamicFiles(
112
112
  {
113
113
  const fileName = README_MD;
114
114
  const templatePath = README_MD_TEMPLATES_PATH;
115
- const template = file.read(templatePath);
115
+ const template = file.read(templatePath, verbose);
116
116
  const readmeMD = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
117
117
  const destinationPath = path.join(projectPath, fileName);
118
118
  file.write(destinationPath, readmeMD, verbose);
@@ -122,7 +122,7 @@ function copyDynamicFiles(
122
122
  {
123
123
  const fileName = METADATA_XML;
124
124
  const templatePath = METADATA_XML_TEMPLATE_PATH;
125
- const template = file.read(templatePath);
125
+ const template = file.read(templatePath, verbose);
126
126
  const metadataXML = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
127
127
  const modPath = path.join(projectPath, "mod");
128
128
  const destinationPath = path.join(modPath, fileName);
@@ -133,7 +133,7 @@ function copyDynamicFiles(
133
133
  {
134
134
  const fileName = METADATA_VDF;
135
135
  const templatePath = METADATA_VDF_TEMPLATE_PATH;
136
- const template = file.read(templatePath);
136
+ const template = file.read(templatePath, verbose);
137
137
  const metadataVDF = template.replace(/MOD_TARGET_DIR/g, targetModDirectory);
138
138
  const modPath = path.join(projectPath, "mod");
139
139
  const destinationPath = path.join(modPath, fileName);
@@ -147,7 +147,7 @@ function copyDynamicFiles(
147
147
  const srcPath = path.join(projectPath, "src");
148
148
  const fileName = MAIN_TS;
149
149
  const templatePath = MAIN_TS_TEMPLATE_PATH;
150
- const template = file.read(templatePath);
150
+ const template = file.read(templatePath, verbose);
151
151
  const mainTS = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
152
152
  const destinationPath = path.join(srcPath, fileName);
153
153
  file.write(destinationPath, mainTS, verbose);
@@ -31,6 +31,7 @@ const DEFAULT_MODS_PATH_LINUX = path.join(
31
31
 
32
32
  export async function getModsDir(
33
33
  argv: Record<string, unknown>,
34
+ verbose: boolean,
34
35
  ): Promise<string> {
35
36
  if (argv.modsDirectory !== undefined) {
36
37
  // They specified the "--mods-directory" command-line flag,
@@ -40,7 +41,10 @@ export async function getModsDir(
40
41
 
41
42
  const defaultModsPath = getDefaultModsPath(process.platform);
42
43
 
43
- if (file.exists(defaultModsPath) && file.isDir(defaultModsPath)) {
44
+ if (
45
+ file.exists(defaultModsPath, verbose) &&
46
+ file.isDir(defaultModsPath, verbose)
47
+ ) {
44
48
  return defaultModsPath;
45
49
  }
46
50
 
@@ -55,7 +59,7 @@ export async function getModsDir(
55
59
  error("Error: You did not provide a response; exiting.");
56
60
  }
57
61
 
58
- if (!file.exists(modsDir)) {
62
+ if (!file.exists(modsDir, verbose)) {
59
63
  error(
60
64
  `Error: The directory of "${chalk.green(
61
65
  modsDir,
@@ -63,7 +67,7 @@ export async function getModsDir(
63
67
  );
64
68
  }
65
69
 
66
- if (!file.isDir(modsDir)) {
70
+ if (!file.isDir(modsDir, verbose)) {
67
71
  error(
68
72
  `Error: The path of "${chalk.green(
69
73
  modsDir,
@@ -2,7 +2,7 @@ import chalk from "chalk";
2
2
  import path from "path";
3
3
  import { CURRENT_DIRECTORY_NAME, CWD } from "../../constants";
4
4
  import { getInputString, getInputYesNo } from "../../prompt";
5
- import { hasWhiteSpace } from "../../utils";
5
+ import { error, hasWhiteSpace, isKebabCase } from "../../utils";
6
6
 
7
7
  // From: https://gist.github.com/doctaphred/d01d05291546186941e1b7ddc02034d3
8
8
  const ILLEGAL_CHARACTERS_FOR_WINDOWS_FILENAMES = [
@@ -46,9 +46,7 @@ export async function getProjectPath(
46
46
  [projectName, projectPath, createNewDir] = await getNewProjectName();
47
47
  }
48
48
 
49
- if (!validateProjectName(projectName)) {
50
- process.exit(1);
51
- }
49
+ validateProjectName(projectName);
52
50
 
53
51
  console.log(`Using a project name of: ${chalk.green(projectName)}`);
54
52
  return [projectPath, createNewDir];
@@ -82,27 +80,28 @@ async function getNewProjectName(): Promise<[string, string, boolean]> {
82
80
 
83
81
  function validateProjectName(projectName: string) {
84
82
  if (projectName === "") {
85
- console.error("Error: You cannot have a blank project name.");
86
- return false;
83
+ error("Error: You cannot have a blank project name.");
87
84
  }
88
85
 
89
86
  if (process.platform === "win32") {
90
87
  for (const character of ILLEGAL_CHARACTERS_FOR_WINDOWS_FILENAMES) {
91
88
  if (projectName.includes(character)) {
92
- console.error(
89
+ error(
93
90
  `Error: The "${character}" character is not allowed in a Windows file name.`,
94
91
  );
95
- return false;
96
92
  }
97
93
  }
98
94
  }
99
95
 
100
96
  if (hasWhiteSpace(projectName)) {
101
- console.error(
97
+ error(
102
98
  'Error: The project name has whitespace in it, which is not allowed. Use kebab-case for your project name. (e.g. "green-candle")',
103
99
  );
104
- return false;
105
100
  }
106
101
 
107
- return true;
102
+ if (!isKebabCase(projectName)) {
103
+ error(
104
+ "Error: The project name is not in kebab-case. (Kebab-case is the style of using all lowercase letters, with words separated by hyphens.) Project names must use kebab-case to match GitHub repository standards.",
105
+ );
106
+ }
108
107
  }
@@ -27,7 +27,7 @@ export async function promptGitHubRepoOrGitRemoteURL(
27
27
 
28
28
  validateNewGitVersion(verbose);
29
29
 
30
- const gitHubUsername = getGitHubUsername();
30
+ const gitHubUsername = getGitHubUsername(verbose);
31
31
  if (gitHubUsername !== undefined) {
32
32
  const [exitStatus] = execShell(
33
33
  "gh",
@@ -131,7 +131,7 @@ function validateNewGitVersion(verbose: boolean) {
131
131
  process.exit(1);
132
132
  }
133
133
 
134
- function getGitHubUsername() {
134
+ function getGitHubUsername(verbose: boolean) {
135
135
  // If the GitHub CLI is installed, we can derive the user's GitHub username
136
136
  if (
137
137
  !commandExists.sync("gh") ||
@@ -146,11 +146,11 @@ function getGitHubUsername() {
146
146
  "GitHub CLI",
147
147
  "hosts.yml",
148
148
  );
149
- if (!file.exists(githubCLIHostsPath)) {
149
+ if (!file.exists(githubCLIHostsPath, verbose)) {
150
150
  return undefined;
151
151
  }
152
152
 
153
- const configYAMLRaw = file.read(githubCLIHostsPath);
153
+ const configYAMLRaw = file.read(githubCLIHostsPath, verbose);
154
154
  const configYAML = yaml.parse(configYAMLRaw) as GitHubCLIHostsYAML;
155
155
 
156
156
  const githubCom = configYAML["github.com"];
@@ -159,7 +159,7 @@ function getGitHubUsername() {
159
159
  }
160
160
 
161
161
  const { user } = githubCom;
162
- if (user === "") {
162
+ if (user === undefined || user === "") {
163
163
  return undefined;
164
164
  }
165
165
 
@@ -27,7 +27,7 @@ export async function init(argv: Record<string, unknown>): Promise<void> {
27
27
  yes,
28
28
  );
29
29
  await checkIfProjectPathExists(projectPath, yes, verbose);
30
- const modsDirectory = await getModsDir(argv);
30
+ const modsDirectory = await getModsDir(argv, verbose);
31
31
  checkModSubdirectory(projectPath, modsDirectory);
32
32
  const projectName = path.basename(projectPath);
33
33
  await checkModTargetDirectory(modsDirectory, projectName, yes, verbose);
@@ -10,7 +10,7 @@ export function installVSCodeExtensions(
10
10
  VSCodeCommand: string,
11
11
  verbose: boolean,
12
12
  ): void {
13
- const extensions = getExtensionsFromJSON(projectPath);
13
+ const extensions = getExtensionsFromJSON(projectPath, verbose);
14
14
  for (const extensionName of extensions) {
15
15
  execShell(VSCodeCommand, ["--install-extension", extensionName], verbose);
16
16
  }
@@ -20,18 +20,18 @@ interface ExtensionsJSON {
20
20
  recommendations: string[];
21
21
  }
22
22
 
23
- function getExtensionsFromJSON(projectPath: string) {
23
+ function getExtensionsFromJSON(projectPath: string, verbose: boolean) {
24
24
  const extensionsJSONPath = path.join(
25
25
  projectPath,
26
26
  ".vscode",
27
27
  "extensions.json",
28
28
  );
29
29
 
30
- if (!file.exists(extensionsJSONPath)) {
30
+ if (!file.exists(extensionsJSONPath, verbose)) {
31
31
  return [];
32
32
  }
33
33
 
34
- const extensionsJSONRaw = file.read(extensionsJSONPath);
34
+ const extensionsJSONRaw = file.read(extensionsJSONPath, verbose);
35
35
 
36
36
  let extensionsJSON: ExtensionsJSON;
37
37
  try {
@@ -12,11 +12,11 @@ export function copyWatcherMod(config: Config, verbose: boolean): void {
12
12
  // Check to see if this mod was disabled
13
13
  const watcherModPath = path.join(config.modsDirectory, WATCHER_MOD_NAME);
14
14
  const disableItPath = path.join(watcherModPath, DISABLE_IT_FILE);
15
- const watcherModDisabled = file.exists(disableItPath);
15
+ const watcherModDisabled = file.exists(disableItPath, verbose);
16
16
 
17
17
  // Delete and re-copy the watcher mod every time IsaacScript starts
18
18
  // This ensures that it is always the latest version
19
- if (file.exists(watcherModPath)) {
19
+ if (file.exists(watcherModPath, verbose)) {
20
20
  file.deleteFileOrDirectory(watcherModPath, verbose);
21
21
  }
22
22
 
@@ -45,7 +45,7 @@ function disableIsaacScriptWatcherAutomaticRestart(
45
45
  verbose: boolean,
46
46
  ) {
47
47
  const mainLuaPath = path.join(watcherModPath, MAIN_LUA);
48
- const mainLua = file.read(mainLuaPath);
48
+ const mainLua = file.read(mainLuaPath, verbose);
49
49
 
50
50
  const modifiedMainLua = mainLua.replace(
51
51
  "local RESTART_GAME_ON_RECOMPILATION = true",
@@ -4,8 +4,8 @@ import { TSCONFIG_PATH } from "../../constants";
4
4
  import * as file from "../../file";
5
5
  import { error } from "../../utils";
6
6
 
7
- export function getTSConfigInclude(): string {
8
- const tsConfigRaw = file.read(TSCONFIG_PATH);
7
+ export function getTSConfigInclude(verbose: boolean): string {
8
+ const tsConfigRaw = file.read(TSCONFIG_PATH, verbose);
9
9
  let tsConfig: Record<string, string[]>;
10
10
  try {
11
11
  tsConfig = JSONC.parse(tsConfigRaw) as Record<string, string[]>;
@@ -29,7 +29,7 @@ export function monitor(argv: Record<string, unknown>, config: Config): void {
29
29
  }
30
30
 
31
31
  // Read the "tsconfig.json" file
32
- const tsConfigInclude = getTSConfigInclude();
32
+ const tsConfigInclude = getTSConfigInclude(verbose);
33
33
  const resolvedIncludePath = path.resolve(CWD, tsConfigInclude);
34
34
  const modTargetDirectoryName = getModTargetDirectoryName(config);
35
35
  const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
@@ -40,7 +40,7 @@ export function monitor(argv: Record<string, unknown>, config: Config): void {
40
40
 
41
41
  // Delete and re-copy the mod every time IsaacScript starts
42
42
  // This ensures that it is always the latest version
43
- if (file.exists(modTargetPath)) {
43
+ if (file.exists(modTargetPath, verbose)) {
44
44
  file.deleteFileOrDirectory(modTargetPath, true);
45
45
  }
46
46
 
@@ -7,14 +7,15 @@ import { ensureAllCases, error } from "../../../utils";
7
7
  import { SaveDatMessage, SaveDatMessageType } from "./types";
8
8
 
9
9
  const MAX_MESSAGES = 100;
10
+ const VERBOSE = false;
10
11
 
11
12
  let saveDatPath: string;
12
13
  let saveDatFileName: string;
13
14
 
14
- init();
15
+ init(VERBOSE);
15
16
 
16
- function init() {
17
- const numArgs = 1;
17
+ function init(verbose: boolean) {
18
+ const numArgs = 2;
18
19
  if (process.argv.length !== 2 + numArgs) {
19
20
  throw new Error(
20
21
  "The Save.dat writer process did not get the right amount of arguments.",
@@ -26,8 +27,8 @@ function init() {
26
27
 
27
28
  // Check to see if the data directory exists
28
29
  const watcherModDataPath = path.dirname(saveDatPath);
29
- if (!file.exists(watcherModDataPath)) {
30
- file.makeDir(watcherModDataPath, false);
30
+ if (!file.exists(watcherModDataPath, verbose)) {
31
+ file.makeDir(watcherModDataPath, verbose);
31
32
  }
32
33
 
33
34
  // Listen for messages from the parent process
@@ -37,7 +38,7 @@ function init() {
37
38
  }
38
39
 
39
40
  function onMessage(type: SaveDatMessageType, data: string, numRetries = 0) {
40
- const saveDat = readSaveDatFromDisk();
41
+ const saveDat = readSaveDatFromDisk(VERBOSE);
41
42
  if (saveDat.length > MAX_MESSAGES) {
42
43
  // If IsaacScript is running and
43
44
  // 1) the game is not open
@@ -50,13 +51,13 @@ function onMessage(type: SaveDatMessageType, data: string, numRetries = 0) {
50
51
  return;
51
52
  }
52
53
  addMessageToSaveDat(type, saveDat, data); // Mutates saveDat
53
- writeSaveDatToDisk(type, data, saveDat, numRetries);
54
+ writeSaveDatToDisk(type, data, saveDat, numRetries, VERBOSE);
54
55
  }
55
56
 
56
- function readSaveDatFromDisk() {
57
+ function readSaveDatFromDisk(verbose: boolean) {
57
58
  let saveDat: SaveDatMessage[];
58
- if (file.exists(saveDatPath)) {
59
- const saveDatRaw = file.read(saveDatPath);
59
+ if (file.exists(saveDatPath, verbose)) {
60
+ const saveDatRaw = file.read(saveDatPath, verbose);
60
61
  try {
61
62
  saveDat = JSONC.parse(saveDatRaw) as SaveDatMessage[];
62
63
  } catch (err) {
@@ -111,11 +112,12 @@ function writeSaveDatToDisk(
111
112
  type: SaveDatMessageType,
112
113
  data: string,
113
114
  saveDat: SaveDatMessage[],
114
- numRetries = 0,
115
+ numRetries: number,
116
+ verbose: boolean,
115
117
  ) {
116
118
  const saveDatRaw = JSON.stringify(saveDat, null, 2);
117
119
  try {
118
- file.writeTry(saveDatPath, saveDatRaw);
120
+ file.writeTry(saveDatPath, saveDatRaw, verbose);
119
121
  } catch (err) {
120
122
  if (numRetries > 4) {
121
123
  console.error(
@@ -9,12 +9,12 @@ export function touchWatcherSaveDatFiles(
9
9
  ): void {
10
10
  const modsDataPath = path.join(config.modsDirectory, "..", "data");
11
11
  const watcherModDataPath = path.join(modsDataPath, WATCHER_MOD_NAME);
12
- if (!file.exists(watcherModDataPath)) {
12
+ if (!file.exists(watcherModDataPath, verbose)) {
13
13
  file.makeDir(watcherModDataPath, verbose);
14
14
  }
15
15
  const saveDatFileName = `save${config.saveSlot}.dat`;
16
16
  const saveDatPath = path.join(watcherModDataPath, saveDatFileName);
17
- if (!file.exists(saveDatPath)) {
17
+ if (!file.exists(saveDatPath, verbose)) {
18
18
  file.touch(saveDatPath, verbose);
19
19
  }
20
20
  }
@@ -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
  }