isaacscript 1.2.2 → 1.2.5

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 (63) hide show
  1. package/dist/package.json +5 -5
  2. package/dist/src/commands/copy/copy.js +12 -10
  3. package/dist/src/commands/copy/copy.js.map +1 -1
  4. package/dist/src/commands/init/checkIfProjectPathExists.js +2 -2
  5. package/dist/src/commands/init/checkIfProjectPathExists.js.map +1 -1
  6. package/dist/src/commands/init/checkModTargetDirectory.js +2 -2
  7. package/dist/src/commands/init/checkModTargetDirectory.js.map +1 -1
  8. package/dist/src/commands/init/createMod.js +65 -44
  9. package/dist/src/commands/init/createMod.js.map +1 -1
  10. package/dist/src/commands/init/init.js +10 -8
  11. package/dist/src/commands/init/init.js.map +1 -1
  12. package/dist/src/commands/init/installVSCodeExtensions.js +3 -2
  13. package/dist/src/commands/init/installVSCodeExtensions.js.map +1 -1
  14. package/dist/src/commands/init/promptVSCode.js +7 -7
  15. package/dist/src/commands/init/promptVSCode.js.map +1 -1
  16. package/dist/src/commands/monitor/copyWatcherMod.js +7 -7
  17. package/dist/src/commands/monitor/copyWatcherMod.js.map +1 -1
  18. package/dist/src/commands/monitor/monitor.js +4 -3
  19. package/dist/src/commands/monitor/monitor.js.map +1 -1
  20. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +1 -1
  21. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
  22. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js +3 -3
  23. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +1 -1
  24. package/dist/src/commands/publish/publish.js +48 -46
  25. package/dist/src/commands/publish/publish.js.map +1 -1
  26. package/dist/src/configFile.js +4 -3
  27. package/dist/src/configFile.js.map +1 -1
  28. package/dist/src/exec.js +79 -0
  29. package/dist/src/exec.js.map +1 -0
  30. package/dist/src/file.js +35 -5
  31. package/dist/src/file.js.map +1 -1
  32. package/dist/src/main.js +1 -1
  33. package/dist/src/main.js.map +1 -1
  34. package/dist/src/monkeyPatch.js +4 -4
  35. package/dist/src/monkeyPatch.js.map +1 -1
  36. package/dist/src/parseArgs.js +20 -1
  37. package/dist/src/parseArgs.js.map +1 -1
  38. package/dist/src/util.js +22 -57
  39. package/dist/src/util.js.map +1 -1
  40. package/dist/src/validateNodeVersion.js +6 -24
  41. package/dist/src/validateNodeVersion.js.map +1 -1
  42. package/file-templates/static/build.sh +1 -1
  43. package/package.json +5 -5
  44. package/src/commands/copy/copy.ts +19 -10
  45. package/src/commands/init/checkIfProjectPathExists.ts +2 -1
  46. package/src/commands/init/checkModTargetDirectory.ts +2 -1
  47. package/src/commands/init/createMod.ts +108 -50
  48. package/src/commands/init/init.ts +15 -7
  49. package/src/commands/init/installVSCodeExtensions.ts +4 -2
  50. package/src/commands/init/promptVSCode.ts +12 -7
  51. package/src/commands/monitor/copyWatcherMod.ts +10 -7
  52. package/src/commands/monitor/monitor.ts +5 -3
  53. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +1 -1
  54. package/src/commands/monitor/touchWatcherSaveDatFiles.ts +6 -3
  55. package/src/commands/publish/publish.ts +66 -55
  56. package/src/configFile.ts +9 -3
  57. package/src/exec.ts +102 -0
  58. package/src/file.ts +48 -5
  59. package/src/main.ts +1 -1
  60. package/src/monkeyPatch.ts +4 -2
  61. package/src/parseArgs.ts +22 -1
  62. package/src/util.ts +29 -79
  63. package/src/validateNodeVersion.ts +7 -39
@@ -27,6 +27,11 @@ function parseArgs() {
27
27
  alias: "c",
28
28
  type: "boolean",
29
29
  description: "Enable crash debugging",
30
+ })
31
+ .option("verbose", {
32
+ alias: "v",
33
+ type: "boolean",
34
+ description: "Enable verbose output",
30
35
  }))
31
36
  .command("init [name]", `Initialize a new ${constants_1.PROJECT_NAME} mod.`, (builder) => builder
32
37
  .option("use-current-dir", {
@@ -54,8 +59,17 @@ function parseArgs() {
54
59
  alias: "i",
55
60
  type: "boolean",
56
61
  description: 'Don\'t automatically run "npm install" after initializing the project',
62
+ })
63
+ .option("verbose", {
64
+ alias: "v",
65
+ type: "boolean",
66
+ description: "Enable verbose output",
67
+ }))
68
+ .command("copy", "Only compile & copy the mod.", (builder) => builder.option("verbose", {
69
+ alias: "v",
70
+ type: "boolean",
71
+ description: "Enable verbose output",
57
72
  }))
58
- .command("copy", "Only compile & copy the mod.")
59
73
  .command("publish", "Bump the version & automatically publish the new files using the steamcmd tool.", (builder) => builder
60
74
  .option("skip", {
61
75
  alias: "s",
@@ -76,6 +90,11 @@ function parseArgs() {
76
90
  alias: "u",
77
91
  type: "boolean",
78
92
  description: "only upload the mod to the Steam Workshop (without doing anything else)",
93
+ })
94
+ .option("verbose", {
95
+ alias: "v",
96
+ type: "boolean",
97
+ description: "Enable verbose output",
79
98
  }))
80
99
  .alias("h", "help") // By default, only "--help" is enabled
81
100
  .alias("v", "version"); // By default, only "--version" is enabled
@@ -1 +1 @@
1
- {"version":3,"file":"parseArgs.js","sourceRoot":"","sources":["../../src/parseArgs.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2CAA2C;AAE3C,SAAgB,SAAS;IACvB,MAAM,WAAW,GAAG,IAAA,eAAK,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC7C,MAAM,EAAE;SACR,KAAK,CAAC,wCAAwC,CAAC;SAC/C,UAAU,CAAC,aAAa,CAAC;SAEzB,OAAO,CAAC,SAAS,EAAE,0CAA0C,EAAE,CAAC,OAAO,EAAE,EAAE,CAC1E,OAAO;SACJ,MAAM,CAAC,gBAAgB,EAAE;QACxB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oDAAoD;KAClE,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACnB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAClB,WAAW,EA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M,CAAC,MAAM,EAAE;QACd,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,sCAAsC;KACpD,CAAC;SACD,MAAM,CAAC,aAAa,EAAE;QACrB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,uDAAuD;KAC1D,CAAC;SACD,MAAM,CAAC,SAAS,EAAE;QACjB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,wBAAwB;KACtC,CAAC;SACD,MAAM,CAAC,aAAa,EAAE;QACrB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,SAAS;QACf,WAAW,EACT,yEAAyE;KAC5E,CAAC;SACD,MAAM,CAAC,SAAS,EAAE;QACjB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,uBAAuB;KACrC,CAAC,CACP;SAEA,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,uCAAuC;SAC1D,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,0CAA0C;IAEpE,OAAO,WAAW,CAAC,IAAI,CAAC;AAC1B,CAAC;AArHD,8BAqHC"}
package/dist/src/util.js CHANGED
@@ -3,9 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseIntSafe = exports.hasWhiteSpace = exports.getTime = exports.getModTargetDirectoryName = exports.execShell = exports.execExe = exports.error = exports.ensureAllCases = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const child_process_1 = require("child_process");
6
+ exports.parseSemVer = exports.parseIntSafe = exports.hasWhiteSpace = exports.getTime = exports.getModTargetDirectoryName = exports.error = exports.ensureAllCases = void 0;
9
7
  const moment_1 = __importDefault(require("moment"));
10
8
  const constants_1 = require("./constants");
11
9
  const ensureAllCases = (obj) => obj;
@@ -15,60 +13,6 @@ function error(...args) {
15
13
  process.exit(1);
16
14
  }
17
15
  exports.error = error;
18
- function execExe(path, cwd = constants_1.CWD) {
19
- let stdout;
20
- try {
21
- const buffer = (0, child_process_1.execSync)(`"${path}"`, {
22
- cwd,
23
- });
24
- stdout = buffer.toString().trim();
25
- }
26
- catch (err) {
27
- console.error(`Failed to run "${chalk_1.default.green(path)}":`, err);
28
- process.exit(1);
29
- }
30
- return stdout;
31
- }
32
- exports.execExe = execExe;
33
- /** Returns an array of exit status and stdout. */
34
- function execShell(command, args = [], allowFailure = false, cwd = constants_1.CWD) {
35
- // On Windows, "spawnSync()" will not account for spaces in arguments
36
- // Thus, wrap everything in a double quote
37
- // This will cause arguments that naturally have double quotes to fail
38
- if (command.includes('"')) {
39
- throw new Error("execShell cannot execute commands with double quotes in the command.");
40
- }
41
- for (let i = 0; i < args.length; i++) {
42
- if (args[i].includes('"')) {
43
- throw new Error("execShell cannot execute commands with double quotes in the arguments.");
44
- }
45
- args[i] = `"${args[i]}"`; // eslint-disable-line no-param-reassign
46
- }
47
- const commandDescription = `${command} ${args.join(" ")}`.trim();
48
- let spawnSyncReturns;
49
- try {
50
- spawnSyncReturns = (0, child_process_1.spawnSync)(command, args, {
51
- shell: true,
52
- cwd,
53
- });
54
- }
55
- catch (err) {
56
- error(`Failed to run the "${chalk_1.default.green(commandDescription)}" command:`, err);
57
- }
58
- const exitStatus = spawnSyncReturns.status;
59
- const stdout = spawnSyncReturns.output.join("\n").trim();
60
- if (exitStatus !== 0) {
61
- if (allowFailure) {
62
- return [exitStatus, stdout];
63
- }
64
- console.error(`Failed to run the "${chalk_1.default.green(commandDescription)}" command with an exit code of ${exitStatus}.`);
65
- console.error("The output was as follows:");
66
- console.error(stdout);
67
- process.exit(1);
68
- }
69
- return [exitStatus, stdout];
70
- }
71
- exports.execShell = execShell;
72
16
  function getModTargetDirectoryName(config) {
73
17
  return config.customTargetModDirectoryName === undefined
74
18
  ? constants_1.CURRENT_DIRECTORY_NAME
@@ -110,4 +54,25 @@ function parseIntSafe(input) {
110
54
  return parseInt(trimmedInput, 10);
111
55
  }
112
56
  exports.parseIntSafe = parseIntSafe;
57
+ function parseSemVer(versionString) {
58
+ const match = /^v*(\d+)\.(\d+)\.(\d+)/g.exec(versionString);
59
+ if (match === null) {
60
+ error(`Failed to parse the version string of: ${versionString}`);
61
+ }
62
+ const [, majorVersionString, minorVersionString, patchVersionString] = match;
63
+ const majorVersion = parseIntSafe(majorVersionString);
64
+ if (Number.isNaN(majorVersion)) {
65
+ error(`Failed to parse the major version number from: ${versionString}`);
66
+ }
67
+ const minorVersion = parseInt(minorVersionString, 10);
68
+ if (Number.isNaN(minorVersion)) {
69
+ error(`Failed to parse the minor version number from: ${versionString}`);
70
+ }
71
+ const patchVersion = parseInt(patchVersionString, 10);
72
+ if (Number.isNaN(patchVersion)) {
73
+ error(`Failed to parse the patch version number from: ${versionString}`);
74
+ }
75
+ return [majorVersion, minorVersion, patchVersion];
76
+ }
77
+ exports.parseSemVer = parseSemVer;
113
78
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iDAAsE;AACtE,oDAA4B;AAC5B,2CAA0D;AAGnD,MAAM,cAAc,GAAG,CAAC,GAAU,EAAS,EAAE,CAAC,GAAG,CAAC;AAA5C,QAAA,cAAc,kBAA8B;AAEzD,SAAgB,KAAK,CAAC,GAAG,IAAe;IACtC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAHD,sBAGC;AAED,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAG,GAAG,eAAG;IAC7C,IAAI,MAAc,CAAC;IACnB,IAAI;QACF,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,IAAI,IAAI,GAAG,EAAE;YACnC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C;IACtD,IAAI,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;QAC9B,KAAK,CAAC,kDAAkD,aAAa,EAAE,CAAC,CAAC;KAC1E;IAED,MAAM,YAAY,GAAG,QAAQ,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACtD,IAAI,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;QAC9B,KAAK,CAAC,kDAAkD,aAAa,EAAE,CAAC,CAAC;KAC1E;IAED,OAAO,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC;AA1BD,kCA0BC"}
@@ -7,36 +7,18 @@ exports.validateNodeVersion = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const constants_1 = require("./constants");
9
9
  const util_1 = require("./util");
10
- const REQUIRED_MAJOR_VERSION = 16;
10
+ const REQUIRED_NODE_JS_MAJOR_VERSION = 16;
11
11
  // This program requires Node to be at least v16.0.0,
12
12
  // since that is the version that added the "fs.rmSync()" function
13
13
  // (I tested on Node v15.0.0 and it failed)
14
14
  function validateNodeVersion() {
15
- const { version } = process;
16
- const match = /^v(\d+)\.(\d+)\.(\d)+$/g.exec(version);
17
- if (match === null) {
18
- (0, util_1.error)(`Failed to parse your NodeJS version of: ${version}`);
19
- }
20
- const majorVersionString = match[1];
21
- const majorVersion = parseInt(majorVersionString, 10);
22
- if (Number.isNaN(majorVersion)) {
23
- (0, util_1.error)(`Failed to parse the major version number from: ${majorVersionString}`);
24
- }
25
- const minorVersionString = match[2];
26
- const minorVersion = parseInt(minorVersionString, 10);
27
- if (Number.isNaN(minorVersion)) {
28
- (0, util_1.error)(`Failed to parse the minor version number from: ${minorVersionString}`);
29
- }
30
- const patchVersionString = match[3];
31
- const patchVersion = parseInt(patchVersionString, 10);
32
- if (Number.isNaN(patchVersion)) {
33
- (0, util_1.error)(`Failed to parse the patch version number from: ${patchVersionString}`);
34
- }
35
- if (majorVersion >= REQUIRED_MAJOR_VERSION) {
15
+ const nodeJSVersionString = process.version;
16
+ const [majorVersion] = (0, util_1.parseSemVer)(nodeJSVersionString);
17
+ if (majorVersion >= REQUIRED_NODE_JS_MAJOR_VERSION) {
36
18
  return;
37
19
  }
38
- console.error(`Your Node.js version is: ${chalk_1.default.red(`${majorVersionString}.${minorVersionString}.${patchVersionString}`)}`);
39
- console.error(`${constants_1.PROJECT_NAME} requires a Node.js version of ${chalk_1.default.red("16.0.0")} or greater.`);
20
+ console.error(`Your Node.js version is: ${chalk_1.default.red(nodeJSVersionString)}`);
21
+ console.error(`${constants_1.PROJECT_NAME} requires a Node.js version of ${chalk_1.default.red(`${REQUIRED_NODE_JS_MAJOR_VERSION}.0.0`)} or greater.`);
40
22
  console.error(`Please upgrade your version of Node.js before using ${constants_1.PROJECT_NAME}.`);
41
23
  process.exit(1);
42
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validateNodeVersion.js","sourceRoot":"","sources":["../../src/validateNodeVersion.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2CAA2C;AAC3C,iCAA+B;AAE/B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,qDAAqD;AACrD,kEAAkE;AAClE,2CAA2C;AAC3C,SAAgB,mBAAmB;IACjC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,MAAM,KAAK,GAAG,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,IAAA,YAAK,EAAC,2CAA2C,OAAO,EAAE,CAAC,CAAC;KAC7D;IAED,MAAM,kBAAkB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,QAAQ,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACtD,IAAI,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;QAC9B,IAAA,YAAK,EACH,kDAAkD,kBAAkB,EAAE,CACvE,CAAC;KACH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AAC,GAAG,IAAA,kBAAW,EAAC,mBAAmB,CAAC,CAAC;IAExD,IAAI,YAAY,IAAI,8BAA8B,EAAE;QAClD,OAAO;KACR;IAED,OAAO,CAAC,KAAK,CAAC,4BAA4B,eAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;IAC5E,OAAO,CAAC,KAAK,CACX,GAAG,wBAAY,kCAAkC,eAAK,CAAC,GAAG,CACxD,GAAG,8BAA8B,MAAM,CACxC,cAAc,CAChB,CAAC;IACF,OAAO,CAAC,KAAK,CACX,uDAAuD,wBAAY,GAAG,CACvE,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAlBD,kDAkBC"}
@@ -8,7 +8,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8
8
 
9
9
  SECONDS=0
10
10
 
11
- # Convert the TypeScript to a single Lua file
11
+ # Convert the TypeScript to a single Lua file (based on the settings in "tsconfig.json")
12
12
  cd "$DIR"
13
13
  npx tstl
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript",
3
- "version": "1.2.2",
3
+ "version": "1.2.5",
4
4
  "description": "A command line tool for managing Isaac mods written in TypeScript",
5
5
  "homepage": "https://isaacscript.github.io/",
6
6
  "bugs": {
@@ -21,12 +21,12 @@
21
21
  "command-exists": "^1.2.9",
22
22
  "dotenv": "^16.0.0",
23
23
  "figlet": "^1.5.2",
24
- "fs-extra": "^10.0.0",
24
+ "fs-extra": "^10.0.1",
25
25
  "isaacscript-tsconfig": "^1.1.8",
26
26
  "jsonc-parser": "^3.0.0",
27
27
  "moment": "^2.29.1",
28
- "npm-check-updates": "^12.2.1",
29
- "prompt": "^1.2.1",
28
+ "npm-check-updates": "^12.4.0",
29
+ "prompt": "^1.2.2",
30
30
  "source-map": "^0.7.3",
31
31
  "source-map-support": "^0.5.21",
32
32
  "sync-directory": "^4.0.12",
@@ -39,7 +39,7 @@
39
39
  "@types/command-exists": "^1.2.0",
40
40
  "@types/figlet": "^1.5.4",
41
41
  "@types/fs-extra": "^9.0.13",
42
- "@types/node": "^17.0.16",
42
+ "@types/node": "^17.0.21",
43
43
  "@types/prompt": "^1.1.2",
44
44
  "@types/source-map-support": "^0.5.4",
45
45
  "@types/update-notifier": "^5.1.0",
@@ -1,33 +1,42 @@
1
1
  import path from "path";
2
2
  import { MOD_SOURCE_PATH } from "../../constants";
3
+ import { execShell } from "../../exec";
3
4
  import * as file from "../../file";
4
5
  import { Config } from "../../types/Config";
5
- import { execShell, getModTargetDirectoryName } from "../../util";
6
+ import { getModTargetDirectoryName } from "../../util";
7
+
8
+ export function copy(argv: Record<string, unknown>, config: Config): void {
9
+ const verbose = argv.verbose === true;
6
10
 
7
- export function copy(config: Config): void {
8
11
  const modTargetDirectoryName = getModTargetDirectoryName(config);
9
12
  const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
10
- compileAndCopy(MOD_SOURCE_PATH, modTargetPath);
13
+
14
+ compileAndCopy(MOD_SOURCE_PATH, modTargetPath, verbose);
11
15
  }
12
16
 
13
17
  export function compileAndCopy(
14
18
  modSourcePath: string,
15
19
  modTargetPath: string,
20
+ verbose: boolean,
16
21
  ): void {
17
- compile();
22
+ compile(verbose);
18
23
  // monkeyPatchMainLua(modSourcePath);
19
- copyMod(modSourcePath, modTargetPath);
24
+ copyMod(modSourcePath, modTargetPath, verbose);
20
25
  }
21
26
 
22
- function compile() {
23
- execShell("npx", ["tstl"]);
27
+ function compile(verbose: boolean) {
28
+ execShell("npx", ["tstl"], verbose);
24
29
  console.log("Mod compiled successfully.");
25
30
  }
26
31
 
27
- function copyMod(modSourcePath: string, modTargetPath: string) {
32
+ function copyMod(
33
+ modSourcePath: string,
34
+ modTargetPath: string,
35
+ verbose: boolean,
36
+ ) {
28
37
  if (file.exists(modTargetPath)) {
29
- file.deleteFileOrDirectory(modTargetPath);
38
+ file.deleteFileOrDirectory(modTargetPath, verbose);
30
39
  }
31
- file.copy(modSourcePath, modTargetPath);
40
+ file.copy(modSourcePath, modTargetPath, verbose);
32
41
  console.log("Mod copied successfully.");
33
42
  }
@@ -6,6 +6,7 @@ import { error } from "../../util";
6
6
 
7
7
  export async function checkIfProjectPathExists(
8
8
  projectPath: string,
9
+ verbose: boolean,
9
10
  ): Promise<void> {
10
11
  if (projectPath !== CWD && file.exists(projectPath)) {
11
12
  const fileType = file.isDir(projectPath) ? "directory" : "file";
@@ -21,6 +22,6 @@ export async function checkIfProjectPathExists(
21
22
  error("Ok then. Good-bye.");
22
23
  }
23
24
 
24
- file.deleteFileOrDirectory(projectPath);
25
+ file.deleteFileOrDirectory(projectPath, verbose);
25
26
  }
26
27
  }
@@ -8,6 +8,7 @@ import { error } from "../../util";
8
8
  export async function checkModTargetDirectory(
9
9
  modsDirectory: string,
10
10
  projectName: string,
11
+ verbose: boolean,
11
12
  ): Promise<void> {
12
13
  const modTargetPath = path.join(modsDirectory, projectName);
13
14
  if (!file.exists(modTargetPath)) {
@@ -31,5 +32,5 @@ export async function checkModTargetDirectory(
31
32
  error("Ok then. You delete it yourself. Good bye.");
32
33
  }
33
34
 
34
- file.deleteFileOrDirectory(modTargetPath);
35
+ file.deleteFileOrDirectory(modTargetPath, verbose);
35
36
  }
@@ -19,10 +19,14 @@ import {
19
19
  README_MD_TEMPLATES_PATH,
20
20
  TEMPLATES_STATIC_DIR,
21
21
  } from "../../constants";
22
+ import { execShell } from "../../exec";
22
23
  import * as file from "../../file";
23
24
  import { getInputString, getInputYesNo } from "../../prompt";
24
25
  import { GitHubCLIHostsYAML } from "../../types/GitHubCLIHostsYAML";
25
- import { execShell } from "../../util";
26
+ import { error, parseSemVer } from "../../util";
27
+
28
+ const REQUIRED_GIT_MAJOR_VERSION = 2;
29
+ const REQUIRED_GIT_MINOR_VERSION = 30;
26
30
 
27
31
  export async function createMod(
28
32
  projectName: string,
@@ -31,41 +35,82 @@ export async function createMod(
31
35
  modsDirectory: string,
32
36
  saveSlot: number,
33
37
  skipNPMInstall: boolean,
38
+ verbose: boolean,
34
39
  ): Promise<void> {
35
40
  if (createNewDir) {
36
- file.makeDir(projectPath);
41
+ file.makeDir(projectPath, verbose);
37
42
  }
38
43
 
39
44
  const config = configFile.createObject(modsDirectory, saveSlot);
40
- configFile.createFile(projectPath, config);
45
+ configFile.createFile(projectPath, config, verbose);
41
46
  const targetModDirectory = path.join(config.modsDirectory, projectName);
42
47
 
43
- makeSubdirectories(projectPath);
44
- copyStaticFiles(projectPath);
45
- copyDynamicFiles(projectName, projectPath, targetModDirectory);
46
- updateNodeModules(projectPath);
47
- await initGitRepository(projectPath, projectName);
48
- installNodeModules(projectPath, skipNPMInstall);
48
+ await initGitRepository(projectPath, projectName, verbose);
49
+ makeSubdirectories(projectPath, verbose);
50
+ copyStaticFiles(projectPath, verbose);
51
+ copyDynamicFiles(projectName, projectPath, targetModDirectory, verbose);
52
+ updateNodeModules(projectPath, verbose);
53
+ installNodeModules(projectPath, skipNPMInstall, verbose);
49
54
 
50
55
  console.log(`Successfully created mod: ${chalk.green(projectName)}`);
51
56
  }
52
57
 
53
- function makeSubdirectories(projectPath: string) {
58
+ async function initGitRepository(
59
+ projectPath: string,
60
+ projectName: string,
61
+ verbose: boolean,
62
+ ) {
63
+ if (!commandExists.sync("git")) {
64
+ console.log(
65
+ 'Git does not seem to be installed. (The "git" command is not in the path.) Skipping Git-related things.',
66
+ );
67
+ return;
68
+ }
69
+
70
+ checkOldGitVersion(verbose);
71
+
72
+ const remoteURL = await getGitRemoteURL(projectName);
73
+ if (remoteURL === "") {
74
+ return;
75
+ }
76
+
77
+ execShell("git", ["init"], verbose, false, projectPath);
78
+ execShell("git", ["branch", "-M", "main"], verbose, false, projectPath);
79
+ execShell(
80
+ "git",
81
+ ["remote", "add", "origin", remoteURL],
82
+ verbose,
83
+ false,
84
+ projectPath,
85
+ );
86
+ if (isGitNameAndEmailConfigured(verbose)) {
87
+ execShell("git", ["add", "--all"], verbose, false, projectPath);
88
+ execShell(
89
+ "git",
90
+ ["commit", "--message", `${PROJECT_NAME} template`],
91
+ verbose,
92
+ false,
93
+ projectPath,
94
+ );
95
+ }
96
+ }
97
+
98
+ function makeSubdirectories(projectPath: string, verbose: boolean) {
54
99
  // The "src" directory is created during copying of static files
55
100
  for (const subdirectory of ["mod"]) {
56
101
  const srcPath = path.join(projectPath, subdirectory);
57
- file.makeDir(srcPath);
102
+ file.makeDir(srcPath, verbose);
58
103
  }
59
104
  }
60
105
 
61
106
  // Copy static files, like ".eslintrc.js", "tsconfig.json", etc.
62
- function copyStaticFiles(projectPath: string) {
107
+ function copyStaticFiles(projectPath: string, verbose: boolean) {
63
108
  const staticFileList = file.getDirList(TEMPLATES_STATIC_DIR);
64
109
  staticFileList.forEach((fileName: string) => {
65
110
  const templateFilePath = path.join(TEMPLATES_STATIC_DIR, fileName);
66
111
  const destinationFilePath = path.join(projectPath, fileName);
67
112
  if (!file.exists(destinationFilePath)) {
68
- file.copy(templateFilePath, destinationFilePath);
113
+ file.copy(templateFilePath, destinationFilePath, verbose);
69
114
  }
70
115
  });
71
116
  }
@@ -75,6 +120,7 @@ function copyDynamicFiles(
75
120
  projectName: string,
76
121
  projectPath: string,
77
122
  targetModDirectory: string,
123
+ verbose: boolean,
78
124
  ) {
79
125
  // ".gitignore"
80
126
  {
@@ -92,7 +138,7 @@ function copyDynamicFiles(
92
138
  const gitignore = gitignoreHeader + template;
93
139
 
94
140
  const destinationPath = path.join(projectPath, `.${fileName}`); // We need to prepend a period
95
- file.write(destinationPath, gitignore);
141
+ file.write(destinationPath, gitignore, verbose);
96
142
  }
97
143
 
98
144
  // "package.json"
@@ -103,7 +149,7 @@ function copyDynamicFiles(
103
149
  const template = file.read(templatePath);
104
150
  const packageJSON = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
105
151
  const destinationPath = path.join(projectPath, fileName);
106
- file.write(destinationPath, packageJSON);
152
+ file.write(destinationPath, packageJSON, verbose);
107
153
  }
108
154
 
109
155
  // "README.md"
@@ -113,7 +159,7 @@ function copyDynamicFiles(
113
159
  const template = file.read(templatePath);
114
160
  const readmeMD = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
115
161
  const destinationPath = path.join(projectPath, fileName);
116
- file.write(destinationPath, readmeMD);
162
+ file.write(destinationPath, readmeMD, verbose);
117
163
  }
118
164
 
119
165
  // "mod/metadata.xml"
@@ -124,7 +170,7 @@ function copyDynamicFiles(
124
170
  const metadataXML = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
125
171
  const modPath = path.join(projectPath, "mod");
126
172
  const destinationPath = path.join(modPath, fileName);
127
- file.write(destinationPath, metadataXML);
173
+ file.write(destinationPath, metadataXML, verbose);
128
174
  }
129
175
 
130
176
  // "mod/metadata.vdf"
@@ -135,7 +181,7 @@ function copyDynamicFiles(
135
181
  const metadataVDF = template.replace(/MOD_TARGET_DIR/g, targetModDirectory);
136
182
  const modPath = path.join(projectPath, "mod");
137
183
  const destinationPath = path.join(modPath, fileName);
138
- file.write(destinationPath, metadataVDF);
184
+ file.write(destinationPath, metadataVDF, verbose);
139
185
  }
140
186
 
141
187
  // "src/main.ts"
@@ -148,47 +194,21 @@ function copyDynamicFiles(
148
194
  const template = file.read(templatePath);
149
195
  const mainTS = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
150
196
  const destinationPath = path.join(srcPath, fileName);
151
- file.write(destinationPath, mainTS);
197
+ file.write(destinationPath, mainTS, verbose);
152
198
  }
153
199
  }
154
200
 
155
- function updateNodeModules(projectPath: string) {
201
+ function updateNodeModules(projectPath: string, verbose: boolean) {
156
202
  console.log("Finding out the latest versions of the NPM packages...");
157
203
  execShell(
158
204
  "npx",
159
205
  ["npm-check-updates", "--upgrade", "--packageFile", "package.json"],
206
+ verbose,
160
207
  false,
161
208
  projectPath,
162
209
  );
163
210
  }
164
211
 
165
- async function initGitRepository(projectPath: string, projectName: string) {
166
- if (!commandExists.sync("git")) {
167
- console.log(
168
- 'Git does not seem to be installed. (The "git" command is not in the path.) Skipping Git-related things.',
169
- );
170
- return;
171
- }
172
-
173
- const remoteURL = await getGitRemoteURL(projectName);
174
- if (remoteURL === "") {
175
- return;
176
- }
177
-
178
- execShell("git", ["init"], false, projectPath);
179
- execShell("git", ["branch", "-M", "main"], false, projectPath);
180
- execShell("git", ["remote", "add", "origin", remoteURL], false, projectPath);
181
- if (isGitNameAndEmailConfigured()) {
182
- execShell("git", ["add", "--all"], false, projectPath);
183
- execShell(
184
- "git",
185
- ["commit", "--message", `${PROJECT_NAME} template`],
186
- false,
187
- projectPath,
188
- );
189
- }
190
- }
191
-
192
212
  async function getGitRemoteURL(projectName: string) {
193
213
  const guessedRemoteURL = guessRemoteURL(projectName);
194
214
  if (guessedRemoteURL !== undefined) {
@@ -211,6 +231,38 @@ If you don't want to initialize a Git repository for this project, press enter t
211
231
  `);
212
232
  }
213
233
 
234
+ function checkOldGitVersion(verbose: boolean) {
235
+ const [, stdout] = execShell("git", ["--version"], verbose);
236
+
237
+ const outputPrefix = "git version ";
238
+ if (!stdout.startsWith(outputPrefix)) {
239
+ error(
240
+ `Failed to parse the output from the "git --version" command: ${stdout}`,
241
+ );
242
+ }
243
+
244
+ const gitVersionString = stdout.slice(outputPrefix.length);
245
+ const [majorVersion, minorVersion] = parseSemVer(gitVersionString);
246
+
247
+ if (
248
+ majorVersion >= REQUIRED_GIT_MAJOR_VERSION &&
249
+ minorVersion >= REQUIRED_GIT_MINOR_VERSION
250
+ ) {
251
+ return;
252
+ }
253
+
254
+ console.error(`Your Git version is: ${chalk.red(gitVersionString)}`);
255
+ console.error(
256
+ `${PROJECT_NAME} requires a Git version of ${chalk.red(
257
+ `${REQUIRED_GIT_MAJOR_VERSION}.${REQUIRED_GIT_MINOR_VERSION}.0`,
258
+ )} or greater.`,
259
+ );
260
+ console.error(
261
+ `Please upgrade your version of Git before using ${PROJECT_NAME}.`,
262
+ );
263
+ process.exit(1);
264
+ }
265
+
214
266
  function guessRemoteURL(projectName: string) {
215
267
  const gitHubUsername = getGitHubUsername();
216
268
  if (gitHubUsername === undefined) {
@@ -255,27 +307,33 @@ function getGitHubUsername() {
255
307
  return user;
256
308
  }
257
309
 
258
- function isGitNameAndEmailConfigured() {
310
+ function isGitNameAndEmailConfigured(verbose: boolean) {
259
311
  const [nameExitStatus] = execShell(
260
312
  "git",
261
313
  ["config", "--global", "user.name"],
314
+ verbose,
262
315
  true,
263
316
  );
264
317
 
265
318
  const [emailExitStatus] = execShell(
266
319
  "git",
267
320
  ["config", "--global", "user.email"],
321
+ verbose,
268
322
  true,
269
323
  );
270
324
 
271
325
  return nameExitStatus === 0 && emailExitStatus === 0;
272
326
  }
273
327
 
274
- function installNodeModules(projectPath: string, skipNPMInstall: boolean) {
328
+ function installNodeModules(
329
+ projectPath: string,
330
+ skipNPMInstall: boolean,
331
+ verbose: boolean,
332
+ ) {
275
333
  if (skipNPMInstall) {
276
334
  return;
277
335
  }
278
336
 
279
337
  console.log("Installing node modules... (This can take a long time.)");
280
- execShell("npm", ["install"], false, projectPath);
338
+ execShell("npm", ["install"], verbose, false, projectPath);
281
339
  }