isaacscript 2.0.6 → 2.0.9
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 +12 -6
- 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 +9 -9
- 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 +12 -6
- package/.cspell.json +0 -25
- 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 -75
- package/build.sh +0 -30
- package/check-file-updates.sh +0 -67
- package/check-file-updates.txt +0 -8
- package/check-gitignore.sh +0 -26
- package/check-orphaned-words.sh +0 -58
- 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 -8
- package/file-templates/dynamic/package.json +0 -20
- package/file-templates/static/.cspell.json.template +0 -21
- 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 -75
- package/file-templates/static/LICENSE +0 -674
- package/file-templates/static/build.sh +0 -15
- package/file-templates/static/check-orphaned-words.sh +0 -58
- 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/.prettierignore-base +0 -5
- package/file-templates/static-alt/.prettierrc-base.js +0 -30
- package/file-templates/static-alt/.vscode/extensions-format.json +0 -8
- package/file-templates/static-alt/.vscode/extensions-typescript.json +0 -9
- package/file-templates/static-alt/.vscode/settings-typescript.json +0 -63
- package/file-templates/static-alt/check-file-updates.sh +0 -67
- 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
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { HOME_DIR, PROJECT_NAME } from "./constants";
|
|
5
|
-
import * as file from "./file";
|
|
6
|
-
import { getInputYesNo } from "./prompt";
|
|
7
|
-
import { error } from "./utils";
|
|
8
|
-
|
|
9
|
-
const BASH_PROFILE_PATH = path.join(HOME_DIR, ".bash_profile");
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* By default, Git Bash for Windows uses MINGW64. This will not work correctly with the prompt
|
|
13
|
-
* library. Try to detect this and warn the end-user.
|
|
14
|
-
*/
|
|
15
|
-
export async function checkForWindowsTerminalBugs(
|
|
16
|
-
verbose: boolean,
|
|
17
|
-
): Promise<void> {
|
|
18
|
-
if (process.platform !== "win32") {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (process.env["SHELL"] !== "C:\\Program Files\\Git\\usr\\bin\\bash.exe") {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
await checkForWindowsBugColor(verbose);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function checkForWindowsBugColor(verbose: boolean) {
|
|
30
|
-
if (process.env["FORCE_COLOR"] === "true") {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
console.error(
|
|
35
|
-
chalk.red(
|
|
36
|
-
`Error: It looks like you are using Git Bash for Windows (MINGW64) without the "${chalk.green(
|
|
37
|
-
"FORCE_COLOR",
|
|
38
|
-
)}" environment variable.`,
|
|
39
|
-
),
|
|
40
|
-
);
|
|
41
|
-
console.error(
|
|
42
|
-
"This is necessary in order for colors to work properly in the terminal.",
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const shouldFixColors = await getInputYesNo(
|
|
46
|
-
"Do you want me to fix this for you?",
|
|
47
|
-
);
|
|
48
|
-
if (!shouldFixColors) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
applyFixesToBashProfile(verbose);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function applyFixesToBashProfile(verbose: boolean) {
|
|
56
|
-
// Check to see if the Bash profile has data.
|
|
57
|
-
let bashProfileContents: string;
|
|
58
|
-
if (file.exists(BASH_PROFILE_PATH, verbose)) {
|
|
59
|
-
bashProfileContents = file.read(BASH_PROFILE_PATH, verbose);
|
|
60
|
-
} else {
|
|
61
|
-
bashProfileContents = "";
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const appendText = getBashProfileAppendText(bashProfileContents);
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
fs.appendFileSync(BASH_PROFILE_PATH, appendText);
|
|
68
|
-
} catch (err) {
|
|
69
|
-
error(`Failed to append text to "${BASH_PROFILE_PATH}":`, err);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
console.log(
|
|
73
|
-
chalk.green("Complete!"),
|
|
74
|
-
`The terminal fixes have been added to: ${chalk.green(BASH_PROFILE_PATH)}`,
|
|
75
|
-
);
|
|
76
|
-
console.log(
|
|
77
|
-
chalk.red(
|
|
78
|
-
"Please close and re-open your terminal, then run this program again.",
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
process.exit(0);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function getBashProfileAppendText(bashProfileContents: string) {
|
|
85
|
-
let newText = "";
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
bashProfileContents !== "" &&
|
|
89
|
-
bashProfileContents[bashProfileContents.length - 1] !== "\n"
|
|
90
|
-
) {
|
|
91
|
-
// If the Bash profile exists and has data, it should end in a newline. Add an extra newline if
|
|
92
|
-
// this is not the case.
|
|
93
|
-
newText += "\n";
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (bashProfileContents !== "") {
|
|
97
|
-
// If the Bash profile exists and has data, add an extra newline between the existing stuff and
|
|
98
|
-
// the new lines added by us.
|
|
99
|
-
newText += "\n";
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
newText += `# Terminal fixes added by ${PROJECT_NAME}\n`;
|
|
103
|
-
newText += "export FORCE_COLOR=true\n";
|
|
104
|
-
|
|
105
|
-
return newText;
|
|
106
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { MOD_SOURCE_PATH } from "../../constants";
|
|
3
|
-
import { execShell } from "../../exec";
|
|
4
|
-
import * as file from "../../file";
|
|
5
|
-
import { Config } from "../../types/Config";
|
|
6
|
-
import { getModTargetDirectoryName } from "../../utils";
|
|
7
|
-
|
|
8
|
-
export function copy(argv: Record<string, unknown>, config: Config): void {
|
|
9
|
-
const verbose = argv["verbose"] === true;
|
|
10
|
-
|
|
11
|
-
const modTargetDirectoryName = getModTargetDirectoryName(config);
|
|
12
|
-
const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
|
|
13
|
-
|
|
14
|
-
compileAndCopy(MOD_SOURCE_PATH, modTargetPath, verbose);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function compileAndCopy(
|
|
18
|
-
modSourcePath: string,
|
|
19
|
-
modTargetPath: string,
|
|
20
|
-
verbose: boolean,
|
|
21
|
-
): void {
|
|
22
|
-
compile(verbose);
|
|
23
|
-
copyMod(modSourcePath, modTargetPath, verbose);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function compile(verbose: boolean) {
|
|
27
|
-
execShell("npx", ["tstl"], verbose);
|
|
28
|
-
console.log("Mod compiled successfully.");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function copyMod(
|
|
32
|
-
modSourcePath: string,
|
|
33
|
-
modTargetPath: string,
|
|
34
|
-
verbose: boolean,
|
|
35
|
-
) {
|
|
36
|
-
if (file.exists(modTargetPath, verbose)) {
|
|
37
|
-
file.deleteFileOrDirectory(modTargetPath, verbose);
|
|
38
|
-
}
|
|
39
|
-
file.copy(modSourcePath, modTargetPath, verbose);
|
|
40
|
-
console.log("Mod copied successfully.");
|
|
41
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { CWD } from "../../constants";
|
|
3
|
-
import * as file from "../../file";
|
|
4
|
-
import { getInputYesNo } from "../../prompt";
|
|
5
|
-
import { error } from "../../utils";
|
|
6
|
-
|
|
7
|
-
export async function checkIfProjectPathExists(
|
|
8
|
-
projectPath: string,
|
|
9
|
-
yes: boolean,
|
|
10
|
-
verbose: boolean,
|
|
11
|
-
): Promise<void> {
|
|
12
|
-
if (projectPath === CWD || !file.exists(projectPath, verbose)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const fileType = file.isDir(projectPath, verbose) ? "directory" : "file";
|
|
17
|
-
|
|
18
|
-
if (yes) {
|
|
19
|
-
file.deleteFileOrDirectory(projectPath, verbose);
|
|
20
|
-
console.log(`Deleted ${fileType}: ${chalk.green(projectPath)}`);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
console.log(
|
|
25
|
-
`A ${fileType} already exists with a name of: ${chalk.green(projectPath)}`,
|
|
26
|
-
);
|
|
27
|
-
const shouldDelete = await getInputYesNo("Do you want me to delete it?");
|
|
28
|
-
|
|
29
|
-
if (!shouldDelete) {
|
|
30
|
-
error("Ok then. Goodbye.");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
file.deleteFileOrDirectory(projectPath, verbose);
|
|
34
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { CWD } from "../../constants";
|
|
3
|
-
import * as file from "../../file";
|
|
4
|
-
import { error } from "../../utils";
|
|
5
|
-
|
|
6
|
-
export function checkModSubdirectory(
|
|
7
|
-
projectPath: string,
|
|
8
|
-
modsDirectory: string,
|
|
9
|
-
): void {
|
|
10
|
-
if (file.isSubDirOf(CWD, modsDirectory)) {
|
|
11
|
-
console.error(
|
|
12
|
-
`Error: The project directory of "${chalk.green(
|
|
13
|
-
projectPath,
|
|
14
|
-
)}" is a subdirectory of "${chalk.green(modsDirectory)}".`,
|
|
15
|
-
);
|
|
16
|
-
error(
|
|
17
|
-
'You are supposed to have your project folder somewhere else on the system than the Isaac mods directory. (This is because we don\'t want to upload the ".git" folder or the TypeScript files to the Steam Workshop.) Exiting.',
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { PROJECT_NAME } from "../../constants";
|
|
4
|
-
import * as file from "../../file";
|
|
5
|
-
import { getInputYesNo } from "../../prompt";
|
|
6
|
-
import { error } from "../../utils";
|
|
7
|
-
|
|
8
|
-
export async function checkModTargetDirectory(
|
|
9
|
-
modsDirectory: string,
|
|
10
|
-
projectName: string,
|
|
11
|
-
yes: boolean,
|
|
12
|
-
verbose: boolean,
|
|
13
|
-
): Promise<void> {
|
|
14
|
-
const modTargetPath = path.join(modsDirectory, projectName);
|
|
15
|
-
if (!file.exists(modTargetPath, verbose)) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const fileType = file.isDir(modTargetPath, verbose) ? "directory" : "file";
|
|
20
|
-
|
|
21
|
-
if (yes) {
|
|
22
|
-
file.deleteFileOrDirectory(modTargetPath, verbose);
|
|
23
|
-
console.log(`Deleted ${fileType}: ${chalk.green(modTargetPath)}`);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
console.log(
|
|
28
|
-
`A ${fileType} already exists at at the mod path of: ${chalk.green(
|
|
29
|
-
modTargetPath,
|
|
30
|
-
)}`,
|
|
31
|
-
);
|
|
32
|
-
console.log(
|
|
33
|
-
`${PROJECT_NAME} will need to sync your project folder with this directory.`,
|
|
34
|
-
);
|
|
35
|
-
const shouldDelete = await getInputYesNo("Do you want me to delete it?");
|
|
36
|
-
|
|
37
|
-
if (!shouldDelete) {
|
|
38
|
-
error("Ok then. Goodbye.");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
file.deleteFileOrDirectory(modTargetPath, verbose);
|
|
42
|
-
}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import * as configFile from "../../configFile";
|
|
4
|
-
import {
|
|
5
|
-
GITIGNORE,
|
|
6
|
-
GITIGNORE_TEMPLATE_PATH,
|
|
7
|
-
MAIN_TS,
|
|
8
|
-
MAIN_TS_TEMPLATE_PATH,
|
|
9
|
-
METADATA_VDF,
|
|
10
|
-
METADATA_VDF_TEMPLATE_PATH,
|
|
11
|
-
METADATA_XML,
|
|
12
|
-
METADATA_XML_TEMPLATE_PATH,
|
|
13
|
-
PACKAGE_JSON,
|
|
14
|
-
PACKAGE_JSON_TEMPLATE_PATH,
|
|
15
|
-
README_MD,
|
|
16
|
-
README_MD_TEMPLATES_PATH,
|
|
17
|
-
TEMPLATES_STATIC_DIR,
|
|
18
|
-
} from "../../constants";
|
|
19
|
-
import { execShell } from "../../exec";
|
|
20
|
-
import * as file from "../../file";
|
|
21
|
-
import { initGitRepository } from "./git";
|
|
22
|
-
|
|
23
|
-
export function createMod(
|
|
24
|
-
projectName: string,
|
|
25
|
-
projectPath: string,
|
|
26
|
-
createNewDir: boolean,
|
|
27
|
-
modsDirectory: string,
|
|
28
|
-
saveSlot: number,
|
|
29
|
-
gitRemoteURL: string | undefined,
|
|
30
|
-
skipNPMInstall: boolean,
|
|
31
|
-
verbose: boolean,
|
|
32
|
-
): void {
|
|
33
|
-
if (createNewDir) {
|
|
34
|
-
file.makeDir(projectPath, verbose);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const config = configFile.createObject(modsDirectory, saveSlot);
|
|
38
|
-
configFile.createFile(projectPath, config, verbose);
|
|
39
|
-
const targetModDirectory = path.join(config.modsDirectory, projectName);
|
|
40
|
-
|
|
41
|
-
makeSubdirectories(projectPath, verbose);
|
|
42
|
-
copyStaticFiles(projectPath, verbose);
|
|
43
|
-
copyDynamicFiles(projectName, projectPath, targetModDirectory, verbose);
|
|
44
|
-
updateNodeModules(projectPath, verbose);
|
|
45
|
-
installNodeModules(projectPath, skipNPMInstall, verbose);
|
|
46
|
-
formatFiles(projectPath, verbose);
|
|
47
|
-
|
|
48
|
-
// Only make the initial commit once all of the files have been copied and formatted
|
|
49
|
-
initGitRepository(projectPath, gitRemoteURL, verbose);
|
|
50
|
-
|
|
51
|
-
console.log(`Successfully created mod: ${chalk.green(projectName)}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function makeSubdirectories(projectPath: string, verbose: boolean) {
|
|
55
|
-
// The "src" directory is created during copying of static files.
|
|
56
|
-
for (const subdirectory of ["mod"]) {
|
|
57
|
-
const srcPath = path.join(projectPath, subdirectory);
|
|
58
|
-
file.makeDir(srcPath, verbose);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** Copy static files, like ".eslintrc.js", "tsconfig.json", etc. */
|
|
63
|
-
function copyStaticFiles(projectPath: string, verbose: boolean) {
|
|
64
|
-
const staticFileList = file.getDirList(TEMPLATES_STATIC_DIR, verbose);
|
|
65
|
-
staticFileList.forEach((fileName: string) => {
|
|
66
|
-
const templateFilePath = path.join(TEMPLATES_STATIC_DIR, fileName);
|
|
67
|
-
const destinationFilePath = path.join(projectPath, fileName);
|
|
68
|
-
if (!file.exists(destinationFilePath, verbose)) {
|
|
69
|
-
file.copy(templateFilePath, destinationFilePath, verbose);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Rename ".cspell.json.template" to ".cspell.json.template". (If it is kept as ".cspell.json",
|
|
74
|
-
// then local spell checking will fail.)
|
|
75
|
-
const cSpellConfigPath = path.join(projectPath, ".cspell.json.template");
|
|
76
|
-
const correctCSpellConfigPath = path.join(projectPath, ".cspell.json");
|
|
77
|
-
file.rename(cSpellConfigPath, correctCSpellConfigPath, verbose);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Copy files that need to have text replaced inside of them. */
|
|
81
|
-
function copyDynamicFiles(
|
|
82
|
-
projectName: string,
|
|
83
|
-
projectPath: string,
|
|
84
|
-
targetModDirectory: string,
|
|
85
|
-
verbose: boolean,
|
|
86
|
-
) {
|
|
87
|
-
// ".gitignore"
|
|
88
|
-
{
|
|
89
|
-
const fileName = GITIGNORE;
|
|
90
|
-
const templatePath = GITIGNORE_TEMPLATE_PATH;
|
|
91
|
-
const template = file.read(templatePath, verbose);
|
|
92
|
-
|
|
93
|
-
// Prepend a header with the project name
|
|
94
|
-
let separatorLine = "# ";
|
|
95
|
-
for (let i = 0; i < projectName.length; i++) {
|
|
96
|
-
separatorLine += "-";
|
|
97
|
-
}
|
|
98
|
-
separatorLine += "\n";
|
|
99
|
-
const gitignoreHeader = `${separatorLine}# ${projectName}\n${separatorLine}\n`;
|
|
100
|
-
const gitignore = gitignoreHeader + template;
|
|
101
|
-
|
|
102
|
-
const destinationPath = path.join(projectPath, `.${fileName}`); // We need to prepend a period
|
|
103
|
-
file.write(destinationPath, gitignore, verbose);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// "package.json"
|
|
107
|
-
{
|
|
108
|
-
// Modify and copy the file
|
|
109
|
-
const fileName = PACKAGE_JSON;
|
|
110
|
-
const templatePath = PACKAGE_JSON_TEMPLATE_PATH;
|
|
111
|
-
const template = file.read(templatePath, verbose);
|
|
112
|
-
const packageJSON = template.replace(/MOD-NAME-TO-REPLACE/g, projectName);
|
|
113
|
-
const destinationPath = path.join(projectPath, fileName);
|
|
114
|
-
file.write(destinationPath, packageJSON, verbose);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// "README.md"
|
|
118
|
-
{
|
|
119
|
-
const fileName = README_MD;
|
|
120
|
-
const templatePath = README_MD_TEMPLATES_PATH;
|
|
121
|
-
const template = file.read(templatePath, verbose);
|
|
122
|
-
const readmeMD = template.replace(/MOD-NAME-TO-REPLACE/g, projectName);
|
|
123
|
-
const destinationPath = path.join(projectPath, fileName);
|
|
124
|
-
file.write(destinationPath, readmeMD, verbose);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// "mod/metadata.xml"
|
|
128
|
-
{
|
|
129
|
-
const fileName = METADATA_XML;
|
|
130
|
-
const templatePath = METADATA_XML_TEMPLATE_PATH;
|
|
131
|
-
const template = file.read(templatePath, verbose);
|
|
132
|
-
const metadataXML = template.replace(/MOD-NAME-TO-REPLACE/g, projectName);
|
|
133
|
-
const modPath = path.join(projectPath, "mod");
|
|
134
|
-
const destinationPath = path.join(modPath, fileName);
|
|
135
|
-
file.write(destinationPath, metadataXML, verbose);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// "mod/metadata.vdf"
|
|
139
|
-
{
|
|
140
|
-
const fileName = METADATA_VDF;
|
|
141
|
-
const templatePath = METADATA_VDF_TEMPLATE_PATH;
|
|
142
|
-
const template = file.read(templatePath, verbose);
|
|
143
|
-
const metadataVDF = template.replace(/MOD-TARGET-DIR/g, targetModDirectory);
|
|
144
|
-
const modPath = path.join(projectPath, "mod");
|
|
145
|
-
const destinationPath = path.join(modPath, fileName);
|
|
146
|
-
file.write(destinationPath, metadataVDF, verbose);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// "src/main.ts"
|
|
150
|
-
{
|
|
151
|
-
// Convert snake_case and kebab-case to camelCase. (Kebab-case in particular will make the
|
|
152
|
-
// example TypeScript file fail to compile.)
|
|
153
|
-
const srcPath = path.join(projectPath, "src");
|
|
154
|
-
const fileName = MAIN_TS;
|
|
155
|
-
const templatePath = MAIN_TS_TEMPLATE_PATH;
|
|
156
|
-
const template = file.read(templatePath, verbose);
|
|
157
|
-
const mainTS = template.replace(/MOD-NAME-TO-REPLACE/g, projectName);
|
|
158
|
-
const destinationPath = path.join(srcPath, fileName);
|
|
159
|
-
file.write(destinationPath, mainTS, verbose);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** The "package.json" file has to be copied first before this step. */
|
|
164
|
-
function updateNodeModules(projectPath: string, verbose: boolean) {
|
|
165
|
-
console.log("Finding out the latest versions of the NPM packages...");
|
|
166
|
-
execShell(
|
|
167
|
-
"npx",
|
|
168
|
-
["npm-check-updates", "--upgrade", "--packageFile", "package.json"],
|
|
169
|
-
verbose,
|
|
170
|
-
false,
|
|
171
|
-
projectPath,
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function installNodeModules(
|
|
176
|
-
projectPath: string,
|
|
177
|
-
skipNPMInstall: boolean,
|
|
178
|
-
verbose: boolean,
|
|
179
|
-
) {
|
|
180
|
-
if (skipNPMInstall) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
console.log("Installing node modules... (This can take a long time.)");
|
|
185
|
-
execShell("npm", ["install"], verbose, false, projectPath);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function formatFiles(projectPath: string, verbose: boolean) {
|
|
189
|
-
execShell(
|
|
190
|
-
"npx",
|
|
191
|
-
["prettier", "--write", projectPath],
|
|
192
|
-
verbose,
|
|
193
|
-
false,
|
|
194
|
-
projectPath,
|
|
195
|
-
);
|
|
196
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { HOME_DIR } from "../../constants";
|
|
4
|
-
import * as file from "../../file";
|
|
5
|
-
import { getInputString } from "../../prompt";
|
|
6
|
-
import { error } from "../../utils";
|
|
7
|
-
|
|
8
|
-
const MODS = "mods";
|
|
9
|
-
|
|
10
|
-
const DEFAULT_MODS_PATH_WINDOWS = path.join(
|
|
11
|
-
"C:",
|
|
12
|
-
"Program Files (x86)",
|
|
13
|
-
"Steam",
|
|
14
|
-
"steamapps",
|
|
15
|
-
"common",
|
|
16
|
-
"The Binding of Isaac Rebirth",
|
|
17
|
-
MODS,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
/** This is a subdirectory of `$HOME`. */
|
|
21
|
-
const DEFAULT_MODS_PATH_LINUX = path.join(
|
|
22
|
-
HOME_DIR,
|
|
23
|
-
".local",
|
|
24
|
-
"share",
|
|
25
|
-
"Steam",
|
|
26
|
-
"steamapps",
|
|
27
|
-
"common",
|
|
28
|
-
"The Binding of Isaac Rebirth",
|
|
29
|
-
MODS,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
export async function getModsDir(
|
|
33
|
-
argv: Record<string, unknown>,
|
|
34
|
-
verbose: boolean,
|
|
35
|
-
): Promise<string> {
|
|
36
|
-
if (argv["modsDirectory"] !== undefined) {
|
|
37
|
-
// They specified the "--mods-directory" command-line flag, so there is no need to prompt the
|
|
38
|
-
// user for it.
|
|
39
|
-
return argv["modsDirectory"] as string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const defaultModsPath = getDefaultModsPath(process.platform);
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
file.exists(defaultModsPath, verbose) &&
|
|
46
|
-
file.isDir(defaultModsPath, verbose)
|
|
47
|
-
) {
|
|
48
|
-
return defaultModsPath;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.error(
|
|
52
|
-
`Failed to find your mods directory at: ${chalk.green(defaultModsPath)}`,
|
|
53
|
-
);
|
|
54
|
-
const modsDir = await getInputString(
|
|
55
|
-
`Enter the full path to the "${MODS}" directory on your system, which should be next to your "isaac-ng.exe" program:`,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
if (modsDir === "") {
|
|
59
|
-
error("Error: You did not provide a response; exiting.");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!file.exists(modsDir, verbose)) {
|
|
63
|
-
error(
|
|
64
|
-
`Error: The directory of "${chalk.green(
|
|
65
|
-
modsDir,
|
|
66
|
-
)}" does not exist. Exiting.`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!file.isDir(modsDir, verbose)) {
|
|
71
|
-
error(
|
|
72
|
-
`Error: The path of "${chalk.green(
|
|
73
|
-
modsDir,
|
|
74
|
-
)}" is not a directory. Exiting.`,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (path.basename(modsDir) !== MODS) {
|
|
79
|
-
error(
|
|
80
|
-
`Error: You entered a path of "${chalk.green(
|
|
81
|
-
modsDir,
|
|
82
|
-
)}", but you need to input a directory with a name of "${MODS}" at the end. Exiting.`,
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return modsDir;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function getDefaultModsPath(platform: string) {
|
|
90
|
-
switch (platform) {
|
|
91
|
-
case "win32": {
|
|
92
|
-
return DEFAULT_MODS_PATH_WINDOWS;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
case "linux": {
|
|
96
|
-
return DEFAULT_MODS_PATH_LINUX;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
default: {
|
|
100
|
-
return error(
|
|
101
|
-
`There does not exist a default mod path for the platform of: ${chalk.green(
|
|
102
|
-
platform,
|
|
103
|
-
)}`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { CURRENT_DIRECTORY_NAME, CWD } from "../../constants";
|
|
4
|
-
import { getInputString, getInputYesNo } from "../../prompt";
|
|
5
|
-
import { error, hasWhiteSpace, isKebabCase } from "../../utils";
|
|
6
|
-
|
|
7
|
-
// From: https://gist.github.com/doctaphred/d01d05291546186941e1b7ddc02034d3
|
|
8
|
-
const ILLEGAL_CHARACTERS_FOR_WINDOWS_FILENAMES = [
|
|
9
|
-
"<",
|
|
10
|
-
">",
|
|
11
|
-
":",
|
|
12
|
-
'"',
|
|
13
|
-
"/",
|
|
14
|
-
"\\",
|
|
15
|
-
"|",
|
|
16
|
-
"?",
|
|
17
|
-
"*",
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export async function getProjectPath(
|
|
21
|
-
argv: Record<string, unknown>,
|
|
22
|
-
useCurrentDir: boolean,
|
|
23
|
-
yes: boolean,
|
|
24
|
-
forceName: boolean,
|
|
25
|
-
): Promise<[string, boolean]> {
|
|
26
|
-
let projectName = getProjectNameFromCommandLineArgument(argv);
|
|
27
|
-
let projectPath: string;
|
|
28
|
-
let createNewDir: boolean;
|
|
29
|
-
if (useCurrentDir) {
|
|
30
|
-
// The "--use-current-dir" command-line flag was specified, so there is no need to prompt the
|
|
31
|
-
// user.
|
|
32
|
-
projectName = CURRENT_DIRECTORY_NAME;
|
|
33
|
-
projectPath = CWD;
|
|
34
|
-
createNewDir = false;
|
|
35
|
-
} else if (projectName !== undefined) {
|
|
36
|
-
// The project name was specified on the command-line.
|
|
37
|
-
projectPath = path.join(CWD, projectName);
|
|
38
|
-
createNewDir = true;
|
|
39
|
-
} else if (yes) {
|
|
40
|
-
// The "--yes" command-line flag was specified and the project name was not specified on the
|
|
41
|
-
// command-line, so default to using the current directory.
|
|
42
|
-
projectName = CURRENT_DIRECTORY_NAME;
|
|
43
|
-
projectPath = CWD;
|
|
44
|
-
createNewDir = false;
|
|
45
|
-
} else {
|
|
46
|
-
// The project name was not specified on the command-line, so prompt the user for it.
|
|
47
|
-
[projectName, projectPath, createNewDir] = await getNewProjectName();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
validateProjectName(projectName, forceName);
|
|
51
|
-
|
|
52
|
-
console.log(`Using a project name of: ${chalk.green(projectName)}`);
|
|
53
|
-
return [projectPath, createNewDir];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function getProjectNameFromCommandLineArgument(
|
|
57
|
-
argv: Record<string, unknown>,
|
|
58
|
-
): string | undefined {
|
|
59
|
-
const name = argv["name"];
|
|
60
|
-
return typeof name === "string" && name !== "" ? name : undefined;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function getNewProjectName(): Promise<[string, string, boolean]> {
|
|
64
|
-
console.log("You did not specify a project name as a command-line argument.");
|
|
65
|
-
const shouldUseCurrentDir = await getInputYesNo(
|
|
66
|
-
`Would you like to create a new project using the current directory "${chalk.green(
|
|
67
|
-
CURRENT_DIRECTORY_NAME,
|
|
68
|
-
)}" as the root?`,
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
if (shouldUseCurrentDir) {
|
|
72
|
-
return [CURRENT_DIRECTORY_NAME, CWD, false];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const projectName = await getInputString("Enter the name of the project:");
|
|
76
|
-
const projectPath = path.join(CWD, projectName);
|
|
77
|
-
|
|
78
|
-
return [projectName, projectPath, true];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function validateProjectName(projectName: string, forceName: boolean) {
|
|
82
|
-
if (projectName === "") {
|
|
83
|
-
error("Error: You cannot have a blank project name.");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (process.platform === "win32") {
|
|
87
|
-
for (const character of ILLEGAL_CHARACTERS_FOR_WINDOWS_FILENAMES) {
|
|
88
|
-
if (projectName.includes(character)) {
|
|
89
|
-
error(
|
|
90
|
-
`Error: The "${character}" character is not allowed in a Windows file name.`,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (forceName) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (hasWhiteSpace(projectName)) {
|
|
101
|
-
error(
|
|
102
|
-
'Error: The project name has whitespace in it, which is not allowed. Use kebab-case for your project name. (e.g. "green-candle")',
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (!isKebabCase(projectName)) {
|
|
107
|
-
error(
|
|
108
|
-
'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. If necessary, you can override this check with the "--force-name" flag.',
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
}
|