isaacscript 1.1.74-dev.3 → 1.2.3
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/dist/package.json +5 -5
- package/dist/src/commands/copy/copy.js +13 -12
- package/dist/src/commands/copy/copy.js.map +1 -1
- package/dist/src/commands/init/checkIfProjectPathExists.js +2 -2
- package/dist/src/commands/init/checkIfProjectPathExists.js.map +1 -1
- package/dist/src/commands/init/checkModTargetDirectory.js +2 -2
- package/dist/src/commands/init/checkModTargetDirectory.js.map +1 -1
- package/dist/src/commands/init/createMod.js +55 -34
- package/dist/src/commands/init/createMod.js.map +1 -1
- package/dist/src/commands/init/init.js +10 -8
- package/dist/src/commands/init/init.js.map +1 -1
- package/dist/src/commands/init/installVSCodeExtensions.js +3 -2
- package/dist/src/commands/init/installVSCodeExtensions.js.map +1 -1
- package/dist/src/commands/init/promptVSCode.js +7 -7
- package/dist/src/commands/init/promptVSCode.js.map +1 -1
- package/dist/src/commands/monitor/copyWatcherMod.js +7 -7
- package/dist/src/commands/monitor/copyWatcherMod.js.map +1 -1
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +4 -4
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +1 -1
- package/dist/src/commands/monitor/monitor.js +4 -3
- package/dist/src/commands/monitor/monitor.js.map +1 -1
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +1 -1
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
- package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js +3 -3
- package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +1 -1
- package/dist/src/commands/publish/publish.js +48 -46
- package/dist/src/commands/publish/publish.js.map +1 -1
- package/dist/src/configFile.js +4 -3
- package/dist/src/configFile.js.map +1 -1
- package/dist/src/exec.js +79 -0
- package/dist/src/exec.js.map +1 -0
- package/dist/src/file.js +35 -5
- package/dist/src/file.js.map +1 -1
- package/dist/src/main.js +1 -1
- package/dist/src/main.js.map +1 -1
- package/dist/src/monkeyPatch.js +8 -14
- package/dist/src/monkeyPatch.js.map +1 -1
- package/dist/src/parseArgs.js +20 -1
- package/dist/src/parseArgs.js.map +1 -1
- package/dist/src/util.js +22 -57
- package/dist/src/util.js.map +1 -1
- package/dist/src/validateNodeVersion.js +6 -24
- package/dist/src/validateNodeVersion.js.map +1 -1
- package/package.json +5 -5
- package/publish.sh +1 -1
- package/src/commands/copy/copy.ts +20 -12
- package/src/commands/init/checkIfProjectPathExists.ts +2 -1
- package/src/commands/init/checkModTargetDirectory.ts +2 -1
- package/src/commands/init/createMod.ts +87 -29
- package/src/commands/init/init.ts +15 -7
- package/src/commands/init/installVSCodeExtensions.ts +4 -2
- package/src/commands/init/promptVSCode.ts +12 -7
- package/src/commands/monitor/copyWatcherMod.ts +10 -7
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +3 -3
- package/src/commands/monitor/monitor.ts +5 -3
- package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +1 -1
- package/src/commands/monitor/touchWatcherSaveDatFiles.ts +6 -3
- package/src/commands/publish/publish.ts +65 -55
- package/src/configFile.ts +9 -3
- package/src/exec.ts +102 -0
- package/src/file.ts +48 -5
- package/src/main.ts +1 -1
- package/src/monkeyPatch.ts +8 -13
- package/src/parseArgs.ts +22 -1
- package/src/util.ts +29 -79
- package/src/validateNodeVersion.ts +7 -39
package/src/util.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { execSync, spawnSync, SpawnSyncReturns } from "child_process";
|
|
3
1
|
import moment from "moment";
|
|
4
|
-
import { CURRENT_DIRECTORY_NAME
|
|
2
|
+
import { CURRENT_DIRECTORY_NAME } from "./constants";
|
|
5
3
|
import { Config } from "./types/Config";
|
|
6
4
|
|
|
7
5
|
export const ensureAllCases = (obj: never): never => obj;
|
|
@@ -11,82 +9,6 @@ export function error(...args: unknown[]): never {
|
|
|
11
9
|
process.exit(1);
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
export function execExe(path: string, cwd = CWD): string {
|
|
15
|
-
let stdout: string;
|
|
16
|
-
try {
|
|
17
|
-
const buffer = execSync(`"${path}"`, {
|
|
18
|
-
cwd,
|
|
19
|
-
});
|
|
20
|
-
stdout = buffer.toString().trim();
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.error(`Failed to run "${chalk.green(path)}":`, err);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return stdout;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Returns an array of exit status and stdout. */
|
|
30
|
-
export function execShell(
|
|
31
|
-
command: string,
|
|
32
|
-
args: string[] = [],
|
|
33
|
-
allowFailure = false,
|
|
34
|
-
cwd = CWD,
|
|
35
|
-
): [number | null, string] {
|
|
36
|
-
// On Windows, "spawnSync()" will not account for spaces in arguments
|
|
37
|
-
// Thus, wrap everything in a double quote
|
|
38
|
-
// This will cause arguments that naturally have double quotes to fail
|
|
39
|
-
if (command.includes('"')) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
"execShell cannot execute commands with double quotes in the command.",
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
for (let i = 0; i < args.length; i++) {
|
|
45
|
-
if (args[i].includes('"')) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
"execShell cannot execute commands with double quotes in the arguments.",
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
args[i] = `"${args[i]}"`; // eslint-disable-line no-param-reassign
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const commandDescription = `${command} ${args.join(" ")}`.trim();
|
|
55
|
-
|
|
56
|
-
let spawnSyncReturns: SpawnSyncReturns<Buffer>;
|
|
57
|
-
try {
|
|
58
|
-
spawnSyncReturns = spawnSync(command, args, {
|
|
59
|
-
shell: true,
|
|
60
|
-
cwd,
|
|
61
|
-
});
|
|
62
|
-
} catch (err) {
|
|
63
|
-
error(
|
|
64
|
-
`Failed to run the "${chalk.green(commandDescription)}" command:`,
|
|
65
|
-
err,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const exitStatus = spawnSyncReturns.status;
|
|
70
|
-
const stdout = spawnSyncReturns.output.join("\n").trim();
|
|
71
|
-
|
|
72
|
-
if (exitStatus !== 0) {
|
|
73
|
-
if (allowFailure) {
|
|
74
|
-
return [exitStatus, stdout];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
console.error(
|
|
78
|
-
`Failed to run the "${chalk.green(
|
|
79
|
-
commandDescription,
|
|
80
|
-
)}" command with an exit code of ${exitStatus}.`,
|
|
81
|
-
);
|
|
82
|
-
console.error("The output was as follows:");
|
|
83
|
-
console.error(stdout);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return [exitStatus, stdout];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
12
|
export function getModTargetDirectoryName(config: Config): string {
|
|
91
13
|
return config.customTargetModDirectoryName === undefined
|
|
92
14
|
? CURRENT_DIRECTORY_NAME
|
|
@@ -132,3 +54,31 @@ export function parseIntSafe(input: string): number {
|
|
|
132
54
|
|
|
133
55
|
return parseInt(trimmedInput, 10);
|
|
134
56
|
}
|
|
57
|
+
|
|
58
|
+
export function parseSemVer(
|
|
59
|
+
versionString: string,
|
|
60
|
+
): [major: number, minor: number, patch: number] {
|
|
61
|
+
const match = /^v*(\d+)\.(\d+)\.(\d+)/g.exec(versionString);
|
|
62
|
+
if (match === null) {
|
|
63
|
+
error(`Failed to parse the version string of: ${versionString}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const [, majorVersionString, minorVersionString, patchVersionString] = match;
|
|
67
|
+
|
|
68
|
+
const majorVersion = parseIntSafe(majorVersionString);
|
|
69
|
+
if (Number.isNaN(majorVersion)) {
|
|
70
|
+
error(`Failed to parse the major version number from: ${versionString}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const minorVersion = parseInt(minorVersionString, 10);
|
|
74
|
+
if (Number.isNaN(minorVersion)) {
|
|
75
|
+
error(`Failed to parse the minor version number from: ${versionString}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const patchVersion = parseInt(patchVersionString, 10);
|
|
79
|
+
if (Number.isNaN(patchVersion)) {
|
|
80
|
+
error(`Failed to parse the patch version number from: ${versionString}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return [majorVersion, minorVersion, patchVersion];
|
|
84
|
+
}
|
|
@@ -1,56 +1,24 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { PROJECT_NAME } from "./constants";
|
|
3
|
-
import {
|
|
3
|
+
import { parseSemVer } from "./util";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const REQUIRED_NODE_JS_MAJOR_VERSION = 16;
|
|
6
6
|
|
|
7
7
|
// This program requires Node to be at least v16.0.0,
|
|
8
8
|
// since that is the version that added the "fs.rmSync()" function
|
|
9
9
|
// (I tested on Node v15.0.0 and it failed)
|
|
10
10
|
export function validateNodeVersion(): void {
|
|
11
|
-
const
|
|
11
|
+
const nodeJSVersionString = process.version;
|
|
12
|
+
const [majorVersion] = parseSemVer(nodeJSVersionString);
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
if (match === null) {
|
|
15
|
-
error(`Failed to parse your NodeJS version of: ${version}`);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const majorVersionString = match[1];
|
|
19
|
-
const majorVersion = parseInt(majorVersionString, 10);
|
|
20
|
-
if (Number.isNaN(majorVersion)) {
|
|
21
|
-
error(
|
|
22
|
-
`Failed to parse the major version number from: ${majorVersionString}`,
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const minorVersionString = match[2];
|
|
27
|
-
const minorVersion = parseInt(minorVersionString, 10);
|
|
28
|
-
if (Number.isNaN(minorVersion)) {
|
|
29
|
-
error(
|
|
30
|
-
`Failed to parse the minor version number from: ${minorVersionString}`,
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const patchVersionString = match[3];
|
|
35
|
-
const patchVersion = parseInt(patchVersionString, 10);
|
|
36
|
-
if (Number.isNaN(patchVersion)) {
|
|
37
|
-
error(
|
|
38
|
-
`Failed to parse the patch version number from: ${patchVersionString}`,
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (majorVersion >= REQUIRED_MAJOR_VERSION) {
|
|
14
|
+
if (majorVersion >= REQUIRED_NODE_JS_MAJOR_VERSION) {
|
|
43
15
|
return;
|
|
44
16
|
}
|
|
45
17
|
|
|
46
|
-
console.error(
|
|
47
|
-
`Your Node.js version is: ${chalk.red(
|
|
48
|
-
`${majorVersionString}.${minorVersionString}.${patchVersionString}`,
|
|
49
|
-
)}`,
|
|
50
|
-
);
|
|
18
|
+
console.error(`Your Node.js version is: ${chalk.red(nodeJSVersionString)}`);
|
|
51
19
|
console.error(
|
|
52
20
|
`${PROJECT_NAME} requires a Node.js version of ${chalk.red(
|
|
53
|
-
|
|
21
|
+
`${REQUIRED_NODE_JS_MAJOR_VERSION}.0.0`,
|
|
54
22
|
)} or greater.`,
|
|
55
23
|
);
|
|
56
24
|
console.error(
|