isaacscript 2.0.4 → 2.0.7
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/src/commands/init/createMod.js +9 -9
- package/dist/src/commands/init/git.js +3 -3
- package/dist/src/commands/init/init.js +2 -2
- package/dist/src/commands/monitor/monitor.js +13 -13
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +2 -2
- package/dist/src/configFile.js +1 -1
- package/dist/src/constants.js +12 -9
- package/dist/src/file.js +1 -1
- package/dist/src/main.js +3 -3
- package/dist/src/utils.js +5 -5
- package/dist/src/validateInIsaacScriptProject.js +1 -1
- package/package.json +11 -6
- package/.cspell-base.json +0 -38
- package/.cspell-check-unused.json +0 -7
- package/.cspell.json +0 -53
- package/.eslintrc.js +0 -28
- package/.gitattributes +0 -9
- package/.github/workflows/ci.yml +0 -47
- package/.prettierignore +0 -5
- package/.prettierrc.js +0 -42
- package/.vscode/extensions.json +0 -9
- package/.vscode/settings.json +0 -73
- package/build.sh +0 -30
- package/check-file-updates.sh +0 -57
- package/check-gitignore.sh +0 -26
- package/check-orphaned-words.sh +0 -53
- package/dist/package.json +0 -50
- package/dist/src/checkForWindowsTerminalBugs.js.map +0 -1
- package/dist/src/commands/copy/copy.js.map +0 -1
- package/dist/src/commands/init/checkIfProjectPathExists.js.map +0 -1
- package/dist/src/commands/init/checkModSubdirectory.js.map +0 -1
- package/dist/src/commands/init/checkModTargetDirectory.js.map +0 -1
- package/dist/src/commands/init/createMod.js.map +0 -1
- package/dist/src/commands/init/getModsDir.js.map +0 -1
- package/dist/src/commands/init/getProjectPath.js.map +0 -1
- package/dist/src/commands/init/git.js.map +0 -1
- package/dist/src/commands/init/init.js.map +0 -1
- package/dist/src/commands/init/installVSCodeExtensions.js.map +0 -1
- package/dist/src/commands/init/promptSaveSlot.js.map +0 -1
- package/dist/src/commands/init/promptVSCode.js.map +0 -1
- package/dist/src/commands/monitor/copyWatcherMod.js.map +0 -1
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +0 -1
- package/dist/src/commands/monitor/monitor.js.map +0 -1
- package/dist/src/commands/monitor/notifyGame.js.map +0 -1
- package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +0 -1
- package/dist/src/commands/monitor/saveDatWriter/types.js.map +0 -1
- package/dist/src/commands/monitor/spawnSaveDatWriter.js.map +0 -1
- package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +0 -1
- package/dist/src/commands/publish/publish.js.map +0 -1
- package/dist/src/configFile.js.map +0 -1
- package/dist/src/constants.js.map +0 -1
- package/dist/src/exec.js.map +0 -1
- package/dist/src/file.js.map +0 -1
- package/dist/src/main.js.map +0 -1
- package/dist/src/parseArgs.js.map +0 -1
- package/dist/src/prompt.js.map +0 -1
- package/dist/src/types/Command.js.map +0 -1
- package/dist/src/types/Config.js.map +0 -1
- package/dist/src/types/GitHubCLIHostsYAML.js.map +0 -1
- package/dist/src/utils.js.map +0 -1
- package/dist/src/validateInIsaacScriptProject.js.map +0 -1
- package/dist/src/validateNodeVersion.js.map +0 -1
- package/dist/src/validateOS.js.map +0 -1
- package/eslint-debug.sh +0 -11
- package/file-templates/dynamic/README.md +0 -3
- package/file-templates/dynamic/gitignore +0 -144
- package/file-templates/dynamic/main.ts +0 -19
- package/file-templates/dynamic/metadata.vdf +0 -6
- package/file-templates/dynamic/metadata.xml +0 -10
- package/file-templates/dynamic/package.json +0 -19
- package/file-templates/static/.cspell-check-unused.json +0 -9
- package/file-templates/static/.cspell.json.template +0 -9
- package/file-templates/static/.env_template +0 -2
- package/file-templates/static/.eslintrc.js +0 -24
- package/file-templates/static/.gitattributes +0 -9
- package/file-templates/static/.github/workflows/ci.yml +0 -53
- package/file-templates/static/.prettierignore +0 -14
- package/file-templates/static/.prettierrc.js +0 -42
- package/file-templates/static/.vscode/extensions.json +0 -10
- package/file-templates/static/.vscode/settings.json +0 -76
- package/file-templates/static/LICENSE +0 -674
- package/file-templates/static/build.sh +0 -15
- package/file-templates/static/check-orphaned-words.sh +0 -53
- package/file-templates/static/lint.sh +0 -39
- package/file-templates/static/nuke.sh +0 -18
- package/file-templates/static/plugins/addCrashDebugStatements.ts +0 -40
- package/file-templates/static/plugins/addIsaacScriptCommentHeader.ts +0 -37
- package/file-templates/static/plugins/noExtendedEnums.ts +0 -66
- package/file-templates/static/publish.sh +0 -10
- package/file-templates/static/run.sh +0 -10
- package/file-templates/static/src/bundleEntry.ts +0 -10
- package/file-templates/static/tsconfig.eslint.json +0 -11
- package/file-templates/static/tsconfig.json +0 -33
- package/file-templates/static/update.sh +0 -21
- package/file-templates/static-alt/.cspell-base.json +0 -38
- package/file-templates/static-alt/.cspell-check-unused-base.json +0 -7
- package/file-templates/static-alt/.prettierignore-base +0 -5
- package/file-templates/static-alt/.prettierrc-base.js +0 -30
- package/file-templates/static-alt/.vscode/extensions-typescript.json +0 -9
- package/file-templates/static-alt/.vscode/settings-typescript.json +0 -63
- package/isaacscript-watcher/.luacheckrc +0 -96
- package/isaacscript-watcher/README.md +0 -8
- package/isaacscript-watcher/main.lua +0 -270
- package/isaacscript-watcher/metadata.xml +0 -7
- package/isaacscript-watcher/resources/gfx/logo.anm2 +0 -27
- package/isaacscript-watcher/resources/gfx/logo.png +0 -0
- package/lint.sh +0 -38
- package/misc/logo.png +0 -0
- package/misc/mouseover.png +0 -0
- package/nuke.sh +0 -18
- package/publish.sh +0 -11
- package/src/checkForWindowsTerminalBugs.ts +0 -106
- package/src/commands/copy/copy.ts +0 -41
- package/src/commands/init/checkIfProjectPathExists.ts +0 -34
- package/src/commands/init/checkModSubdirectory.ts +0 -20
- package/src/commands/init/checkModTargetDirectory.ts +0 -42
- package/src/commands/init/createMod.ts +0 -196
- package/src/commands/init/getModsDir.ts +0 -107
- package/src/commands/init/getProjectPath.ts +0 -111
- package/src/commands/init/git.ts +0 -249
- package/src/commands/init/init.ts +0 -93
- package/src/commands/init/installVSCodeExtensions.ts +0 -47
- package/src/commands/init/promptSaveSlot.ts +0 -27
- package/src/commands/init/promptVSCode.ts +0 -33
- package/src/commands/monitor/copyWatcherMod.ts +0 -54
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +0 -67
- package/src/commands/monitor/monitor.ts +0 -180
- package/src/commands/monitor/notifyGame.ts +0 -59
- package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +0 -145
- package/src/commands/monitor/saveDatWriter/types.ts +0 -6
- package/src/commands/monitor/spawnSaveDatWriter.ts +0 -36
- package/src/commands/monitor/touchWatcherSaveDatFiles.ts +0 -20
- package/src/commands/publish/publish.ts +0 -392
- package/src/configFile.ts +0 -80
- package/src/constants.ts +0 -85
- package/src/exec.ts +0 -125
- package/src/file.ts +0 -235
- package/src/main.ts +0 -131
- package/src/parseArgs.ts +0 -127
- package/src/prompt.ts +0 -109
- package/src/types/Command.ts +0 -3
- package/src/types/Config.ts +0 -23
- package/src/types/GitHubCLIHostsYAML.ts +0 -7
- package/src/utils.ts +0 -92
- package/src/validateInIsaacScriptProject.ts +0 -35
- package/src/validateNodeVersion.ts +0 -29
- package/src/validateOS.ts +0 -20
- package/tsconfig.eslint.json +0 -11
- package/tsconfig.json +0 -21
- package/update.sh +0 -21
package/src/constants.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import os from "os";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
const cwd = process.cwd();
|
|
5
|
-
|
|
6
|
-
// https://stackoverflow.com/questions/9080085/node-js-find-home-directory-in-platform-agnostic-way
|
|
7
|
-
const homeDir = os.homedir();
|
|
8
|
-
|
|
9
|
-
// Miscellaneous
|
|
10
|
-
export const CURRENT_DIRECTORY_NAME = path.basename(cwd);
|
|
11
|
-
export const CWD = cwd;
|
|
12
|
-
export const HOME_DIR = homeDir;
|
|
13
|
-
export const FILE_SYNCED_MESSAGE = "File synced:";
|
|
14
|
-
export const MOD_UPLOADER_PATH =
|
|
15
|
-
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\tools\\ModUploader\\ModUploader.exe";
|
|
16
|
-
export const PROJECT_NAME = "IsaacScript";
|
|
17
|
-
|
|
18
|
-
// isaacscript
|
|
19
|
-
const REPO_ROOT = path.join(__dirname, "..", "..");
|
|
20
|
-
|
|
21
|
-
// isaacscript/isaacscript-watcher
|
|
22
|
-
export const DISABLE_IT_FILE = "disable.it";
|
|
23
|
-
export const WATCHER_MOD_NAME = "isaacscript-watcher";
|
|
24
|
-
export const WATCHER_MOD_SOURCE_PATH = path.join(REPO_ROOT, WATCHER_MOD_NAME);
|
|
25
|
-
|
|
26
|
-
// isaacscript/file-templates
|
|
27
|
-
const TEMPLATES_DIR = path.join(REPO_ROOT, "file-templates");
|
|
28
|
-
|
|
29
|
-
// isaacscript/file-templates/static
|
|
30
|
-
export const TEMPLATES_STATIC_DIR = path.join(TEMPLATES_DIR, "static");
|
|
31
|
-
|
|
32
|
-
// isaacscript/file-templates/dynamic
|
|
33
|
-
const TEMPLATES_DYNAMIC_DIR = path.join(TEMPLATES_DIR, "dynamic");
|
|
34
|
-
export const GITIGNORE = "gitignore"; // Not named ".gitignore" to prevent NPM from deleting it
|
|
35
|
-
export const GITIGNORE_TEMPLATE_PATH = path.join(
|
|
36
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
37
|
-
GITIGNORE,
|
|
38
|
-
);
|
|
39
|
-
export const MAIN_TS = "main.ts";
|
|
40
|
-
export const MAIN_TS_TEMPLATE_PATH = path.join(TEMPLATES_DYNAMIC_DIR, MAIN_TS);
|
|
41
|
-
export const METADATA_XML = "metadata.xml";
|
|
42
|
-
export const METADATA_XML_TEMPLATE_PATH = path.join(
|
|
43
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
44
|
-
METADATA_XML,
|
|
45
|
-
);
|
|
46
|
-
export const METADATA_VDF = "metadata.vdf";
|
|
47
|
-
export const METADATA_VDF_TEMPLATE_PATH = path.join(
|
|
48
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
49
|
-
METADATA_VDF,
|
|
50
|
-
);
|
|
51
|
-
export const PACKAGE_JSON = "package.json";
|
|
52
|
-
export const PACKAGE_JSON_TEMPLATE_PATH = path.join(
|
|
53
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
54
|
-
PACKAGE_JSON,
|
|
55
|
-
);
|
|
56
|
-
export const README_MD = "README.md";
|
|
57
|
-
export const README_MD_TEMPLATES_PATH = path.join(
|
|
58
|
-
TEMPLATES_DYNAMIC_DIR,
|
|
59
|
-
README_MD,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// project
|
|
63
|
-
export const CONFIG_FILE_NAME = "isaacscript.json";
|
|
64
|
-
export const CONFIG_FILE_PATH = path.join(CWD, CONFIG_FILE_NAME);
|
|
65
|
-
export const TSCONFIG_PATH = path.join(CWD, "tsconfig.json");
|
|
66
|
-
export const PACKAGE_JSON_PATH = path.join(CWD, "package.json");
|
|
67
|
-
export const CONSTANTS_TS_PATH = path.join(CWD, "src", "constants.ts");
|
|
68
|
-
export const YARN_LOCK_PATH = path.join(CWD, "yarn.lock");
|
|
69
|
-
|
|
70
|
-
// project/mod
|
|
71
|
-
export const MOD_SOURCE_PATH = path.join(CWD, "mod");
|
|
72
|
-
export const MAIN_LUA = "main.lua";
|
|
73
|
-
export const METADATA_XML_PATH = path.join(MOD_SOURCE_PATH, "metadata.xml");
|
|
74
|
-
export const VERSION_TXT_PATH = path.join(MOD_SOURCE_PATH, "version.txt");
|
|
75
|
-
|
|
76
|
-
// project/scripts
|
|
77
|
-
const SCRIPTS_PATH = path.join(CWD, "scripts");
|
|
78
|
-
export const PUBLISH_PRE_COPY_PY_PATH = path.join(
|
|
79
|
-
SCRIPTS_PATH,
|
|
80
|
-
"publish_pre_copy.py",
|
|
81
|
-
);
|
|
82
|
-
export const PUBLISH_POST_COPY_PY_PATH = path.join(
|
|
83
|
-
SCRIPTS_PATH,
|
|
84
|
-
"publish_post_copy.py",
|
|
85
|
-
);
|
package/src/exec.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { execSync, spawnSync, SpawnSyncReturns } from "child_process";
|
|
3
|
-
import { CWD } from "./constants";
|
|
4
|
-
import { error } from "./utils";
|
|
5
|
-
|
|
6
|
-
export function execExe(path: string, verbose: boolean, cwd = CWD): string {
|
|
7
|
-
if (verbose) {
|
|
8
|
-
console.log(`Executing binary: ${path}`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let stdout: string;
|
|
12
|
-
try {
|
|
13
|
-
const buffer = execSync(`"${path}"`, {
|
|
14
|
-
cwd,
|
|
15
|
-
});
|
|
16
|
-
stdout = buffer.toString().trim();
|
|
17
|
-
} catch (err) {
|
|
18
|
-
error(`Failed to run "${chalk.green(path)}":`, err);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (verbose) {
|
|
22
|
-
console.log(`Executed binary: ${path}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return stdout;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function execPowershell(
|
|
29
|
-
command: string,
|
|
30
|
-
verbose = false,
|
|
31
|
-
cwd = CWD,
|
|
32
|
-
): string {
|
|
33
|
-
if (verbose) {
|
|
34
|
-
console.log(`Executing PowerShell command: ${command}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let stdout: string;
|
|
38
|
-
try {
|
|
39
|
-
const buffer = execSync(command, {
|
|
40
|
-
shell: "powershell.exe",
|
|
41
|
-
cwd,
|
|
42
|
-
});
|
|
43
|
-
stdout = buffer.toString().trim();
|
|
44
|
-
} catch (err) {
|
|
45
|
-
error(`Failed to run PowerShell command "${chalk.green(command)}":`, err);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (verbose) {
|
|
49
|
-
console.log(`Executed PowerShell command: ${command}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return stdout;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Returns a tuple of exit status and stdout. The stdout is trimmed for convenience. */
|
|
56
|
-
export function execShell(
|
|
57
|
-
command: string,
|
|
58
|
-
args: string[] = [],
|
|
59
|
-
verbose = false,
|
|
60
|
-
allowFailure = false,
|
|
61
|
-
cwd = CWD,
|
|
62
|
-
): [exitStatus: number, stdout: string] {
|
|
63
|
-
// On Windows, "spawnSync()" will not account for spaces in arguments. Thus, wrap everything in a
|
|
64
|
-
// double quote. This will cause arguments that naturally have double quotes to fail.
|
|
65
|
-
if (command.includes('"')) {
|
|
66
|
-
error(
|
|
67
|
-
"execShell cannot execute commands with double quotes in the command.",
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const argsHasDoubleQuotes = args.some((arg) => arg.includes('"'));
|
|
72
|
-
if (argsHasDoubleQuotes) {
|
|
73
|
-
error(
|
|
74
|
-
"execShell cannot execute commands with double quotes in the arguments.",
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const quotedArgs = args.map((arg) => `"${arg}"`);
|
|
79
|
-
const commandDescription = `${command} ${quotedArgs.join(" ")}`.trim();
|
|
80
|
-
|
|
81
|
-
if (verbose) {
|
|
82
|
-
console.log(`Executing command: ${commandDescription}`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
let spawnSyncReturns: SpawnSyncReturns<Buffer>;
|
|
86
|
-
try {
|
|
87
|
-
spawnSyncReturns = spawnSync(command, args, {
|
|
88
|
-
shell: true,
|
|
89
|
-
cwd,
|
|
90
|
-
});
|
|
91
|
-
} catch (err) {
|
|
92
|
-
error(
|
|
93
|
-
`Failed to run the "${chalk.green(commandDescription)}" command:`,
|
|
94
|
-
err,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (verbose) {
|
|
99
|
-
console.log(`Executed command: ${commandDescription}`);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const exitStatus = spawnSyncReturns.status;
|
|
103
|
-
if (exitStatus === null) {
|
|
104
|
-
error(`Failed to get the return status of command: ${commandDescription}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const stdout = spawnSyncReturns.output.join("\n").trim();
|
|
108
|
-
|
|
109
|
-
if (exitStatus !== 0) {
|
|
110
|
-
if (allowFailure) {
|
|
111
|
-
return [exitStatus, stdout];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
console.error(
|
|
115
|
-
`Failed to run the "${chalk.green(
|
|
116
|
-
commandDescription,
|
|
117
|
-
)}" command with an exit code of ${exitStatus}.`,
|
|
118
|
-
);
|
|
119
|
-
console.error("The output was as follows:");
|
|
120
|
-
console.error(stdout);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return [exitStatus, stdout];
|
|
125
|
-
}
|
package/src/file.ts
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { error } from "./utils";
|
|
5
|
-
|
|
6
|
-
export function copy(srcPath: string, dstPath: string, verbose: boolean): void {
|
|
7
|
-
if (verbose) {
|
|
8
|
-
console.log(`Copying: ${srcPath} --> ${dstPath}`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
// "copySync()" is a "fs-extra" method for copying directories recursively
|
|
13
|
-
fs.copySync(srcPath, dstPath, {
|
|
14
|
-
recursive: true,
|
|
15
|
-
});
|
|
16
|
-
} catch (err) {
|
|
17
|
-
error(
|
|
18
|
-
`Failed to copy directory "${chalk.green(srcPath)}" to "${chalk.green(
|
|
19
|
-
dstPath,
|
|
20
|
-
)}":`,
|
|
21
|
-
err,
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (verbose) {
|
|
26
|
-
console.log(`Copied: ${srcPath} --> ${dstPath}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function deleteFileOrDirectory(
|
|
31
|
-
filePath: string,
|
|
32
|
-
verbose: boolean,
|
|
33
|
-
): void {
|
|
34
|
-
if (verbose) {
|
|
35
|
-
console.log(`Deleting: ${filePath}`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
fs.rmSync(filePath, {
|
|
40
|
-
recursive: true,
|
|
41
|
-
});
|
|
42
|
-
} catch (err) {
|
|
43
|
-
error(
|
|
44
|
-
`Failed to delete file or directory "${chalk.green(filePath)}":`,
|
|
45
|
-
err,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (verbose) {
|
|
50
|
-
console.log(`Deleted: ${filePath}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
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
|
-
|
|
59
|
-
let pathExists: boolean;
|
|
60
|
-
try {
|
|
61
|
-
pathExists = fs.existsSync(filePath);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
error(`Failed to check if "${chalk.green(filePath)}" exists:`, err);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (verbose) {
|
|
67
|
-
console.log(`Path exists: ${pathExists}`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return pathExists;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function getDirList(dirPath: string, verbose: boolean): string[] {
|
|
74
|
-
if (verbose) {
|
|
75
|
-
console.log(`Getting a directory list from: ${dirPath}`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let fileList: string[];
|
|
79
|
-
try {
|
|
80
|
-
fileList = fs.readdirSync(dirPath);
|
|
81
|
-
} catch (err) {
|
|
82
|
-
error(
|
|
83
|
-
`Failed to get the files in the "${chalk.green(dirPath)}" directory:`,
|
|
84
|
-
err,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (verbose) {
|
|
89
|
-
console.log(`Got a directory list from: ${dirPath}`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return fileList;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function getFileStats(filePath: string, verbose: boolean): fs.Stats {
|
|
96
|
-
if (verbose) {
|
|
97
|
-
console.log(`Getting file stats from: ${filePath}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let fileStats: fs.Stats;
|
|
101
|
-
try {
|
|
102
|
-
fileStats = fs.statSync(filePath);
|
|
103
|
-
} catch (err) {
|
|
104
|
-
error(`Failed to get the file stats for "${chalk.green(filePath)}":`, err);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (verbose) {
|
|
108
|
-
console.log(`Got file stats from: ${filePath}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return fileStats;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function isDir(filePath: string, verbose: boolean): boolean {
|
|
115
|
-
const fileStats = getFileStats(filePath, verbose);
|
|
116
|
-
return fileStats.isDirectory();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function isSubDirOf(dir: string, parent: string): boolean {
|
|
120
|
-
const relative = path.relative(parent, dir);
|
|
121
|
-
return (
|
|
122
|
-
relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative)
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function makeDir(dirPath: string, verbose: boolean): void {
|
|
127
|
-
if (verbose) {
|
|
128
|
-
console.log(`Making a directory: ${dirPath}`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
fs.mkdirSync(dirPath, {
|
|
133
|
-
recursive: true,
|
|
134
|
-
});
|
|
135
|
-
} catch (err) {
|
|
136
|
-
error(`Failed to create the "${chalk.green(dirPath)}" directory:`, err);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (verbose) {
|
|
140
|
-
console.log(`Made a directory: ${dirPath}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function read(filePath: string, verbose: boolean): string {
|
|
145
|
-
if (verbose) {
|
|
146
|
-
console.log(`Reading a file: ${filePath}`);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
let fileContents: string;
|
|
150
|
-
try {
|
|
151
|
-
fileContents = fs.readFileSync(filePath, "utf8");
|
|
152
|
-
} catch (err) {
|
|
153
|
-
error(`Failed to read the "${chalk.green(filePath)}" file:`, err);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (verbose) {
|
|
157
|
-
console.log(`Read a file: ${filePath}`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return fileContents;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export function rename(
|
|
164
|
-
srcPath: string,
|
|
165
|
-
dstPath: string,
|
|
166
|
-
verbose: boolean,
|
|
167
|
-
): void {
|
|
168
|
-
if (verbose) {
|
|
169
|
-
console.log(`Renaming: ${srcPath} --> ${dstPath}`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
fs.renameSync(srcPath, dstPath);
|
|
174
|
-
} catch (err) {
|
|
175
|
-
error(
|
|
176
|
-
`Failed to rename "${chalk.green(srcPath)}" to "${chalk.green(
|
|
177
|
-
dstPath,
|
|
178
|
-
)}":`,
|
|
179
|
-
err,
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (verbose) {
|
|
184
|
-
console.log(`Renamed: ${srcPath} --> ${dstPath}`);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export function touch(filePath: string, verbose: boolean): void {
|
|
189
|
-
if (verbose) {
|
|
190
|
-
console.log(`Touching: ${filePath}`);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
const fileHandle = fs.openSync(filePath, "w");
|
|
195
|
-
fs.closeSync(fileHandle);
|
|
196
|
-
} catch (err) {
|
|
197
|
-
error(`Failed to touch the "${chalk.green(filePath)}" file:`, err);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (verbose) {
|
|
201
|
-
console.log(`Touched: ${filePath}`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export function write(filePath: string, data: string, verbose: boolean): void {
|
|
206
|
-
if (verbose) {
|
|
207
|
-
console.log(`Writing data to: ${filePath}`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
try {
|
|
211
|
-
fs.writeFileSync(filePath, data);
|
|
212
|
-
} catch (err) {
|
|
213
|
-
error(`Failed to write to the "${chalk.green(filePath)}" file:`, err);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (verbose) {
|
|
217
|
-
console.log(`Wrote data to: ${filePath}`);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export function writeTry(
|
|
222
|
-
filePath: string,
|
|
223
|
-
data: string,
|
|
224
|
-
verbose: boolean,
|
|
225
|
-
): void {
|
|
226
|
-
if (verbose) {
|
|
227
|
-
console.log(`Writing data to: ${filePath}`);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
fs.writeFileSync(filePath, data);
|
|
231
|
-
|
|
232
|
-
if (verbose) {
|
|
233
|
-
console.log(`Wrote data to: ${filePath}`);
|
|
234
|
-
}
|
|
235
|
-
}
|
package/src/main.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import * as dotenv from "dotenv";
|
|
5
|
-
import figlet from "figlet";
|
|
6
|
-
import path from "path";
|
|
7
|
-
import sourceMapSupport from "source-map-support";
|
|
8
|
-
import updateNotifier from "update-notifier";
|
|
9
|
-
import pkg from "../package.json";
|
|
10
|
-
import { checkForWindowsTerminalBugs } from "./checkForWindowsTerminalBugs";
|
|
11
|
-
import { copy } from "./commands/copy/copy";
|
|
12
|
-
import { init } from "./commands/init/init";
|
|
13
|
-
import { monitor } from "./commands/monitor/monitor";
|
|
14
|
-
import { publish } from "./commands/publish/publish";
|
|
15
|
-
import * as configFile from "./configFile";
|
|
16
|
-
import { CWD, PROJECT_NAME, YARN_LOCK_PATH } from "./constants";
|
|
17
|
-
import { execShell } from "./exec";
|
|
18
|
-
import * as file from "./file";
|
|
19
|
-
import { parseArgs } from "./parseArgs";
|
|
20
|
-
import { promptInit } from "./prompt";
|
|
21
|
-
import { Command, DEFAULT_COMMAND } from "./types/Command";
|
|
22
|
-
import { Config } from "./types/Config";
|
|
23
|
-
import { ensureAllCases, error } from "./utils";
|
|
24
|
-
import { validateInIsaacScriptProject } from "./validateInIsaacScriptProject";
|
|
25
|
-
import { validateNodeVersion } from "./validateNodeVersion";
|
|
26
|
-
import { validateOS } from "./validateOS";
|
|
27
|
-
|
|
28
|
-
main().catch((err) => {
|
|
29
|
-
error(`${PROJECT_NAME} failed:`, err);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
async function main(): Promise<void> {
|
|
33
|
-
sourceMapSupport.install();
|
|
34
|
-
promptInit();
|
|
35
|
-
validateNodeVersion();
|
|
36
|
-
validateOS();
|
|
37
|
-
loadEnvironmentVariables();
|
|
38
|
-
|
|
39
|
-
// Get command line arguments
|
|
40
|
-
const argv = parseArgs();
|
|
41
|
-
const verbose = argv["verbose"] === true;
|
|
42
|
-
|
|
43
|
-
printBanner();
|
|
44
|
-
|
|
45
|
-
// Check for a new version
|
|
46
|
-
updateNotifier({ pkg }).notify();
|
|
47
|
-
|
|
48
|
-
// Pre-flight checks
|
|
49
|
-
await checkForWindowsTerminalBugs(verbose);
|
|
50
|
-
|
|
51
|
-
await handleCommands(argv, verbose);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function loadEnvironmentVariables() {
|
|
55
|
-
const envFile = path.join(CWD, ".env");
|
|
56
|
-
dotenv.config({ path: envFile });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function printBanner() {
|
|
60
|
-
console.log(chalk.green(figlet.textSync(PROJECT_NAME)));
|
|
61
|
-
const bannerLength = 55; // From measuring the banner created by Figlet
|
|
62
|
-
const version = `v${pkg.version}`;
|
|
63
|
-
const leftPaddingAmount = Math.floor((bannerLength + version.length) / 2);
|
|
64
|
-
console.log(version.padStart(leftPaddingAmount));
|
|
65
|
-
console.log();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function handleCommands(argv: Record<string, unknown>, verbose: boolean) {
|
|
69
|
-
const positionalArgs = argv["_"] as string[];
|
|
70
|
-
let command: Command;
|
|
71
|
-
if (positionalArgs.length > 0) {
|
|
72
|
-
command = positionalArgs[0] as Command;
|
|
73
|
-
} else {
|
|
74
|
-
command = DEFAULT_COMMAND;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let config = new Config();
|
|
78
|
-
if (command !== "init") {
|
|
79
|
-
validateInIsaacScriptProject(verbose);
|
|
80
|
-
config = await configFile.get(argv);
|
|
81
|
-
|
|
82
|
-
ensureDepsAreInstalled(verbose);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
switch (command) {
|
|
86
|
-
case "monitor": {
|
|
87
|
-
monitor(argv, config);
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
case "init": {
|
|
92
|
-
await init(argv);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
case "copy": {
|
|
97
|
-
copy(argv, config);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
case "publish": {
|
|
102
|
-
publish(argv, config);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
default: {
|
|
107
|
-
ensureAllCases(command);
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (command !== "monitor") {
|
|
113
|
-
process.exit(0);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function ensureDepsAreInstalled(verbose: boolean) {
|
|
118
|
-
if (file.exists(YARN_LOCK_PATH, verbose)) {
|
|
119
|
-
console.log(
|
|
120
|
-
'Running "yarn" to ensure that the project\'s dependencies are installed correctly.',
|
|
121
|
-
);
|
|
122
|
-
execShell("yarn");
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// https://stackoverflow.com/questions/57016579/checking-if-package-json-dependencies-match-the-installed-dependencies
|
|
127
|
-
console.log(
|
|
128
|
-
'Running "npm install" to ensure that the project\'s dependencies are installed correctly.',
|
|
129
|
-
);
|
|
130
|
-
execShell("npm", ["install"], verbose);
|
|
131
|
-
}
|
package/src/parseArgs.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import yargs from "yargs";
|
|
2
|
-
import { PROJECT_NAME } from "./constants";
|
|
3
|
-
|
|
4
|
-
export function parseArgs(): Record<string, unknown> {
|
|
5
|
-
const yargsObject = yargs(process.argv.slice(2))
|
|
6
|
-
.strict()
|
|
7
|
-
.usage("usage: isaacscript <command> [options]")
|
|
8
|
-
.scriptName("isaacscript")
|
|
9
|
-
|
|
10
|
-
.command("monitor", "Monitor a project for changes. (default)", (builder) =>
|
|
11
|
-
builder
|
|
12
|
-
.option("mods-directory", {
|
|
13
|
-
alias: "m",
|
|
14
|
-
type: "string",
|
|
15
|
-
description: "The directory where Isaac mods live on your system",
|
|
16
|
-
})
|
|
17
|
-
.option("save-slot", {
|
|
18
|
-
alias: "s",
|
|
19
|
-
type: "number",
|
|
20
|
-
choices: [1, 2, 3],
|
|
21
|
-
description: "The save slot in-game that you use",
|
|
22
|
-
})
|
|
23
|
-
.option("verbose", {
|
|
24
|
-
alias: "v",
|
|
25
|
-
type: "boolean",
|
|
26
|
-
description: "Enable verbose output",
|
|
27
|
-
}),
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
.command(
|
|
31
|
-
"init [name]",
|
|
32
|
-
`Initialize a new ${PROJECT_NAME} mod.`,
|
|
33
|
-
(builder) =>
|
|
34
|
-
builder
|
|
35
|
-
.option("yes", {
|
|
36
|
-
alias: "y",
|
|
37
|
-
type: "boolean",
|
|
38
|
-
description:
|
|
39
|
-
'Answer yes to every dialog option, similar to how "npm init --yes" works.',
|
|
40
|
-
})
|
|
41
|
-
.option("use-current-dir", {
|
|
42
|
-
alias: "u",
|
|
43
|
-
type: "boolean",
|
|
44
|
-
description:
|
|
45
|
-
"Use the current directory as the root for the project",
|
|
46
|
-
})
|
|
47
|
-
.option("mods-directory", {
|
|
48
|
-
alias: "m",
|
|
49
|
-
type: "string",
|
|
50
|
-
description: "The directory where Isaac mods live on your system",
|
|
51
|
-
})
|
|
52
|
-
.option("save-slot", {
|
|
53
|
-
alias: "s",
|
|
54
|
-
type: "number",
|
|
55
|
-
choices: [1, 2, 3],
|
|
56
|
-
description: "The in-game save slot that you use",
|
|
57
|
-
})
|
|
58
|
-
.option("vscode", {
|
|
59
|
-
alias: "c",
|
|
60
|
-
type: "boolean",
|
|
61
|
-
description: "Open the project in VSCode after initialization",
|
|
62
|
-
})
|
|
63
|
-
.option("skip-npm-install", {
|
|
64
|
-
alias: "i",
|
|
65
|
-
type: "boolean",
|
|
66
|
-
description:
|
|
67
|
-
'Don\'t automatically run "npm install" after initializing the project',
|
|
68
|
-
})
|
|
69
|
-
.option("force-name", {
|
|
70
|
-
alias: "f",
|
|
71
|
-
type: "boolean",
|
|
72
|
-
description: "Allow project names that are normally illegal",
|
|
73
|
-
})
|
|
74
|
-
.option("verbose", {
|
|
75
|
-
alias: "v",
|
|
76
|
-
type: "boolean",
|
|
77
|
-
description: "Enable verbose output",
|
|
78
|
-
}),
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
.command("copy", "Only compile & copy the mod.", (builder) =>
|
|
82
|
-
builder.option("verbose", {
|
|
83
|
-
alias: "v",
|
|
84
|
-
type: "boolean",
|
|
85
|
-
description: "Enable verbose output",
|
|
86
|
-
}),
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
.command(
|
|
90
|
-
"publish",
|
|
91
|
-
"Bump the version & automatically publish the new files using the steamcmd tool.",
|
|
92
|
-
(builder) =>
|
|
93
|
-
builder
|
|
94
|
-
.option("skip", {
|
|
95
|
-
alias: "s",
|
|
96
|
-
type: "boolean",
|
|
97
|
-
description: "skip incrementing the version number",
|
|
98
|
-
})
|
|
99
|
-
.option("set-version", {
|
|
100
|
-
alias: "t",
|
|
101
|
-
type: "string",
|
|
102
|
-
description:
|
|
103
|
-
"specify the version number instead of incrementing it",
|
|
104
|
-
})
|
|
105
|
-
.option("dry-run", {
|
|
106
|
-
alias: "d",
|
|
107
|
-
type: "boolean",
|
|
108
|
-
description: "skip invoking steamcmd",
|
|
109
|
-
})
|
|
110
|
-
.option("only-upload", {
|
|
111
|
-
alias: "u",
|
|
112
|
-
type: "boolean",
|
|
113
|
-
description:
|
|
114
|
-
"only upload the mod to the Steam Workshop (without doing anything else)",
|
|
115
|
-
})
|
|
116
|
-
.option("verbose", {
|
|
117
|
-
alias: "v",
|
|
118
|
-
type: "boolean",
|
|
119
|
-
description: "Enable verbose output",
|
|
120
|
-
}),
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
.alias("h", "help") // By default, only "--help" is enabled
|
|
124
|
-
.alias("v", "version"); // By default, only "--version" is enabled
|
|
125
|
-
|
|
126
|
-
return yargsObject.argv as Record<string, unknown>;
|
|
127
|
-
}
|