isaacscript 3.15.3 → 3.16.1-dev.0
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/checkForWindowsTerminalBugs.js +57 -0
- package/{src → dist}/classes/Config.js +1 -6
- package/dist/classes/ValidatedConfig.js +1 -0
- package/{src → dist}/commands/check/check.js +67 -64
- package/dist/commands/check/check.test.js +86 -0
- package/dist/commands/copy/copy.js +29 -0
- package/dist/commands/init/checkIfProjectPathExists.js +21 -0
- package/dist/commands/init/checkModSubdirectory.js +9 -0
- package/dist/commands/init/checkModTargetDirectory.js +24 -0
- package/dist/commands/init/createProject.js +199 -0
- package/dist/commands/init/getAuthorName.js +22 -0
- package/dist/commands/init/getModsDir.js +48 -0
- package/dist/commands/init/getProjectPath.js +84 -0
- package/dist/commands/init/init.js +73 -0
- package/dist/commands/init/installVSCodeExtensions.js +27 -0
- package/dist/commands/init/promptSaveSlot.js +17 -0
- package/{src → dist}/commands/init/promptVSCode.js +5 -10
- package/dist/commands/monitor/copyWatcherMod.js +31 -0
- package/dist/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +44 -0
- package/dist/commands/monitor/monitor.js +154 -0
- package/{src → dist}/commands/monitor/notifyGame.js +14 -22
- package/{src → dist}/commands/monitor/saveDatWriter/saveDatWriter.js +24 -27
- package/dist/commands/monitor/saveDatWriter/types.js +1 -0
- package/dist/commands/monitor/spawnModDirectorySyncer.js +31 -0
- package/dist/commands/monitor/spawnSaveDatWriter.js +29 -0
- package/dist/commands/monitor/spawnTSTLWatcher.js +74 -0
- package/dist/commands/monitor/touchWatcherSaveDatFiles.js +15 -0
- package/dist/commands/publish/isaacscriptMod.js +90 -0
- package/dist/commands/publish/prePublish.js +105 -0
- package/dist/commands/publish/publish.js +39 -0
- package/dist/commands/publish/validate.js +46 -0
- package/dist/common.js +65 -0
- package/dist/configFile.js +54 -0
- package/dist/constants.js +61 -0
- package/dist/customStage.js +298 -0
- package/dist/dev.js +10 -0
- package/{src/enums → dist/enums/copied}/DoorSlot.js +5 -6
- package/dist/enums/copied/DoorSlotFlag.js +35 -0
- package/{src/enums → dist/enums/copied}/RoomShape.js +5 -6
- package/{src → dist}/exec.js +19 -28
- package/dist/git.js +133 -0
- package/dist/interfaces/GitHubCLIHostsYAML.js +1 -0
- package/dist/interfaces/IsaacScriptTSConfig.js +1 -0
- package/dist/interfaces/ShadersXML.js +1 -0
- package/dist/interfaces/copied/CustomStageTSConfig.js +4 -0
- package/dist/interfaces/copied/JSONRoomsFile.js +4 -0
- package/dist/main.js +132 -0
- package/dist/objects/copied/doorSlotToDoorSlotFlag.js +16 -0
- package/dist/objects/copied/roomShapeToDoorSlotCoordinates.js +112 -0
- package/dist/packageManager.js +68 -0
- package/{src → dist}/parseArgs.js +36 -15
- package/dist/prompt.js +79 -0
- package/dist/tsconfig.js +98 -0
- package/dist/types/Command.js +4 -0
- package/dist/utils.js +8 -0
- package/dist/validateInIsaacScriptProject.js +29 -0
- package/dist/validateNodeVersion.js +20 -0
- package/file-templates/dynamic/.github/workflows/setup/action.yml +21 -0
- package/file-templates/dynamic/.yarnrc.yml +1 -0
- package/file-templates/dynamic/README.mod.md +4 -3
- package/file-templates/dynamic/_gitignore +0 -2
- package/file-templates/dynamic/package.mod.json +8 -0
- package/file-templates/dynamic/package.ts.json +5 -1
- package/file-templates/{dynamic → static}/.github/workflows/ci.yml +10 -38
- package/file-templates/static/scripts/tsconfig.json +28 -0
- package/file-templates/static-mod/.vscode/settings.json +1 -1
- package/file-templates/static-mod/{_cspell.json → _cspell.jsonc} +2 -2
- package/file-templates/static-mod/_eslintrc.cjs +1 -1
- package/file-templates/static-mod/prettier.config.mjs +6 -1
- package/file-templates/static-mod/scripts/lint.ts +36 -0
- package/file-templates/static-mod/tsconfig.json +5 -5
- package/file-templates/static-ts/.vscode/settings.json +1 -1
- package/file-templates/static-ts/{_cspell.json → _cspell.jsonc} +5 -5
- package/file-templates/static-ts/_eslintrc.cjs +1 -1
- package/file-templates/static-ts/knip.jsonc +6 -0
- package/file-templates/static-ts/prettier.config.mjs +6 -1
- package/file-templates/static-ts/scripts/lint.ts +30 -0
- package/file-templates/static-ts/tsconfig.json +3 -3
- package/package.json +27 -9
- package/plugins/addCrashDebugStatements.cjs +56 -0
- package/plugins/addCrashDebugStatements.ts +39 -0
- package/{src/plugins/addIsaacScriptCommentHeader.js → plugins/addIsaacScriptCommentHeader.cjs} +1 -1
- package/plugins/addIsaacScriptCommentHeader.ts +42 -0
- package/{src/plugins/addIsaacScriptCommentHeaderCommon.js → plugins/addIsaacScriptCommentHeaderCommon.cjs} +6 -4
- package/plugins/addIsaacScriptCommentHeaderCommon.ts +59 -0
- package/{src/plugins/noExtendedEnums.js → plugins/noExtendedEnums.cjs} +25 -4
- package/plugins/noExtendedEnums.ts +83 -0
- package/plugins/tsconfig.json +28 -0
- package/schemas/tsconfig-isaacscript-section-schema.json +1 -0
- package/file-templates/static/nuke.sh +0 -53
- package/file-templates/static/update.sh +0 -26
- package/file-templates/static-mod/build.sh +0 -22
- package/file-templates/static-mod/lint.sh +0 -43
- package/file-templates/static-mod/publish.sh +0 -10
- package/file-templates/static-mod/run.sh +0 -10
- package/file-templates/static-ts/build.sh +0 -53
- package/file-templates/static-ts/lint.sh +0 -35
- package/file-templates/static-ts/publish.sh +0 -10
- package/file-templates/static-ts/run.sh +0 -42
- package/src/checkForWindowsTerminalBugs.js +0 -71
- package/src/checkForWindowsTerminalBugs.js.map +0 -1
- package/src/classes/Config.js.map +0 -1
- package/src/classes/ValidatedConfig.js +0 -3
- package/src/classes/ValidatedConfig.js.map +0 -1
- package/src/commands/check/check.js.map +0 -1
- package/src/commands/check/check.test.js +0 -87
- package/src/commands/check/check.test.js.map +0 -1
- package/src/commands/copy/copy.js +0 -38
- package/src/commands/copy/copy.js.map +0 -1
- package/src/commands/init/checkIfProjectPathExists.js +0 -28
- package/src/commands/init/checkIfProjectPathExists.js.map +0 -1
- package/src/commands/init/checkModSubdirectory.js +0 -16
- package/src/commands/init/checkModSubdirectory.js.map +0 -1
- package/src/commands/init/checkModTargetDirectory.js +0 -31
- package/src/commands/init/checkModTargetDirectory.js.map +0 -1
- package/src/commands/init/createProject.js +0 -215
- package/src/commands/init/createProject.js.map +0 -1
- package/src/commands/init/getAuthorName.js +0 -27
- package/src/commands/init/getAuthorName.js.map +0 -1
- package/src/commands/init/getModsDir.js +0 -58
- package/src/commands/init/getModsDir.js.map +0 -1
- package/src/commands/init/getProjectPath.js +0 -89
- package/src/commands/init/getProjectPath.js.map +0 -1
- package/src/commands/init/init.js +0 -78
- package/src/commands/init/init.js.map +0 -1
- package/src/commands/init/installVSCodeExtensions.js +0 -35
- package/src/commands/init/installVSCodeExtensions.js.map +0 -1
- package/src/commands/init/promptSaveSlot.js +0 -22
- package/src/commands/init/promptSaveSlot.js.map +0 -1
- package/src/commands/init/promptVSCode.js.map +0 -1
- package/src/commands/monitor/copyWatcherMod.js +0 -39
- package/src/commands/monitor/copyWatcherMod.js.map +0 -1
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +0 -47
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +0 -1
- package/src/commands/monitor/monitor.js +0 -263
- package/src/commands/monitor/monitor.js.map +0 -1
- package/src/commands/monitor/notifyGame.js.map +0 -1
- package/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +0 -1
- package/src/commands/monitor/saveDatWriter/types.js +0 -3
- package/src/commands/monitor/saveDatWriter/types.js.map +0 -1
- package/src/commands/monitor/spawnSaveDatWriter.js +0 -35
- package/src/commands/monitor/spawnSaveDatWriter.js.map +0 -1
- package/src/commands/monitor/touchWatcherSaveDatFiles.js +0 -21
- package/src/commands/monitor/touchWatcherSaveDatFiles.js.map +0 -1
- package/src/commands/publish/isaacscriptMod.js +0 -97
- package/src/commands/publish/isaacscriptMod.js.map +0 -1
- package/src/commands/publish/prePublish.js +0 -120
- package/src/commands/publish/prePublish.js.map +0 -1
- package/src/commands/publish/publish.js +0 -42
- package/src/commands/publish/publish.js.map +0 -1
- package/src/commands/publish/validate.js +0 -58
- package/src/commands/publish/validate.js.map +0 -1
- package/src/common.js +0 -69
- package/src/common.js.map +0 -1
- package/src/configFile.js +0 -64
- package/src/configFile.js.map +0 -1
- package/src/constants.js +0 -65
- package/src/constants.js.map +0 -1
- package/src/customStage.js +0 -304
- package/src/customStage.js.map +0 -1
- package/src/dev.js +0 -19
- package/src/dev.js.map +0 -1
- package/src/enums/DoorSlot.js.map +0 -1
- package/src/enums/DoorSlotFlag.js +0 -37
- package/src/enums/DoorSlotFlag.js.map +0 -1
- package/src/enums/PackageManager.js +0 -10
- package/src/enums/PackageManager.js.map +0 -1
- package/src/enums/RoomShape.js.map +0 -1
- package/src/exec.js.map +0 -1
- package/src/file.js +0 -247
- package/src/file.js.map +0 -1
- package/src/git.js +0 -154
- package/src/git.js.map +0 -1
- package/src/interfaces/GitHubCLIHostsYAML.js +0 -3
- package/src/interfaces/GitHubCLIHostsYAML.js.map +0 -1
- package/src/interfaces/IsaacScriptTSConfig.js +0 -3
- package/src/interfaces/IsaacScriptTSConfig.js.map +0 -1
- package/src/interfaces/ShadersXML.js +0 -3
- package/src/interfaces/ShadersXML.js.map +0 -1
- package/src/interfaces/copied/CustomStageTSConfig.js +0 -4
- package/src/interfaces/copied/CustomStageTSConfig.js.map +0 -1
- package/src/interfaces/copied/JSONRoomsFile.js +0 -4
- package/src/interfaces/copied/JSONRoomsFile.js.map +0 -1
- package/src/isaacScriptCommonTS.js +0 -233
- package/src/isaacScriptCommonTS.js.map +0 -1
- package/src/json.js +0 -42
- package/src/json.js.map +0 -1
- package/src/main.js +0 -127
- package/src/main.js.map +0 -1
- package/src/objects/doorSlotToDoorSlotFlag.js +0 -17
- package/src/objects/doorSlotToDoorSlotFlag.js.map +0 -1
- package/src/objects/roomShapeDoorToSlotCoordinates.js +0 -115
- package/src/objects/roomShapeDoorToSlotCoordinates.js.map +0 -1
- package/src/packageManager.js +0 -153
- package/src/packageManager.js.map +0 -1
- package/src/parseArgs.js.map +0 -1
- package/src/plugins/addCrashDebugStatements.js +0 -32
- package/src/plugins/addCrashDebugStatements.js.map +0 -1
- package/src/plugins/addIsaacScriptCommentHeader.js.map +0 -1
- package/src/plugins/addIsaacScriptCommentHeaderCommon.js.map +0 -1
- package/src/plugins/noExtendedEnums.js.map +0 -1
- package/src/prompt.js +0 -87
- package/src/prompt.js.map +0 -1
- package/src/tsconfig.js +0 -103
- package/src/tsconfig.js.map +0 -1
- package/src/types/Command.js +0 -9
- package/src/types/Command.js.map +0 -1
- package/src/utils.js +0 -15
- package/src/utils.js.map +0 -1
- package/src/validateInIsaacScriptProject.js +0 -36
- package/src/validateInIsaacScriptProject.js.map +0 -1
- package/src/validateNodeVersion.js +0 -29
- package/src/validateNodeVersion.js.map +0 -1
- package/src/version.js +0 -20
- package/src/version.js.map +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { appendFile, isFile, readFile } from "isaacscript-common-node";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { HOME_DIR, PROJECT_NAME } from "./constants.js";
|
|
5
|
+
import { getInputYesNo } from "./prompt.js";
|
|
6
|
+
const BASH_PROFILE_PATH = path.join(HOME_DIR, ".bash_profile");
|
|
7
|
+
/**
|
|
8
|
+
* By default, Git Bash for Windows uses MINGW64. This will not work correctly with the prompt
|
|
9
|
+
* library. Try to detect this and warn the end-user.
|
|
10
|
+
*/
|
|
11
|
+
export async function checkForWindowsTerminalBugs() {
|
|
12
|
+
if (process.platform !== "win32") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (process.env["SHELL"] !== "C:\\Program Files\\Git\\usr\\bin\\bash.exe") {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
await checkForWindowsBugColor();
|
|
19
|
+
}
|
|
20
|
+
async function checkForWindowsBugColor() {
|
|
21
|
+
if (process.env["FORCE_COLOR"] === "true") {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
console.error(chalk.red(`Error: It looks like you are using Git Bash for Windows (MINGW64) without the "${chalk.green("FORCE_COLOR")}" environment variable.`));
|
|
25
|
+
console.error("This is necessary in order for colors to work properly in the terminal.");
|
|
26
|
+
const shouldFixColors = await getInputYesNo("Do you want me to fix this for you?");
|
|
27
|
+
if (!shouldFixColors) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
applyFixesToBashProfile();
|
|
31
|
+
}
|
|
32
|
+
function applyFixesToBashProfile() {
|
|
33
|
+
// Check to see if the Bash profile has data.
|
|
34
|
+
const bashProfileContents = isFile(BASH_PROFILE_PATH)
|
|
35
|
+
? readFile(BASH_PROFILE_PATH)
|
|
36
|
+
: "";
|
|
37
|
+
const appendText = getBashProfileAppendText(bashProfileContents);
|
|
38
|
+
appendFile(BASH_PROFILE_PATH, appendText);
|
|
39
|
+
console.log(`The terminal fixes have been added to: ${chalk.green(BASH_PROFILE_PATH)}`, chalk.red("Please close and re-open your terminal, then run this program again."));
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
function getBashProfileAppendText(bashProfileContents) {
|
|
43
|
+
let newText = "";
|
|
44
|
+
if (bashProfileContents !== "" && !bashProfileContents.endsWith("\n")) {
|
|
45
|
+
// If the Bash profile exists and has data, it should end in a newline. Add an extra newline if
|
|
46
|
+
// this is not the case.
|
|
47
|
+
newText += "\n";
|
|
48
|
+
}
|
|
49
|
+
if (bashProfileContents !== "") {
|
|
50
|
+
// If the Bash profile exists and has data, add an extra newline between the existing stuff and
|
|
51
|
+
// the new lines added by us.
|
|
52
|
+
newText += "\n";
|
|
53
|
+
}
|
|
54
|
+
newText += `# Terminal fixes added by ${PROJECT_NAME}\n`;
|
|
55
|
+
newText += "export FORCE_COLOR=true\n";
|
|
56
|
+
return newText;
|
|
57
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// - Note that all mandatory properties must be explicitly validated in `configFile.ts`.
|
|
3
2
|
// - The types are explicitly annotated to work around a bug in `ts-json-schema-generator`:
|
|
4
3
|
// https://github.com/vega/ts-json-schema-generator/issues/1531
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Config = void 0;
|
|
7
4
|
/** This is the format for the "isaacscript.json" file. */
|
|
8
|
-
class Config {
|
|
5
|
+
export class Config {
|
|
9
6
|
// Marked as public to disable `knip` warnings.
|
|
10
7
|
/** @public */
|
|
11
8
|
$schema = "https://raw.githubusercontent.com/IsaacScript/isaacscript/main/packages/isaacscript-cli/schemas/isaacscript-schema.json";
|
|
@@ -41,5 +38,3 @@ class Config {
|
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
exports.Config = Config;
|
|
45
|
-
//# sourceMappingURL=Config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const PackageManager_js_1 = require("../../enums/PackageManager.js");
|
|
10
|
-
const exec_js_1 = require("../../exec.js");
|
|
11
|
-
const file_js_1 = require("../../file.js");
|
|
12
|
-
const isaacScriptCommonTS_js_1 = require("../../isaacScriptCommonTS.js");
|
|
13
|
-
const packageManager_js_1 = require("../../packageManager.js");
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { PACKAGE_MANAGER_LOCK_FILE_NAMES, PackageManager, deleteFileOrDirectory, fatalError, isDirectory, isFile, readFile, writeFile, } from "isaacscript-common-node";
|
|
3
|
+
import { ReadonlySet, getEnumValues, trimPrefix } from "isaacscript-common-ts";
|
|
4
|
+
import klawSync from "klaw-sync";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { ACTION_YML, ACTION_YML_TEMPLATE_PATH, CWD, TEMPLATES_DIR, TEMPLATES_DYNAMIC_DIR, TEMPLATES_STATIC_DIR, YARNRC_TEMPLATE_PATH, YARNRC_YML, } from "../../constants.js";
|
|
7
|
+
import { execShell } from "../../exec.js";
|
|
8
|
+
import { getPackageManagerUsedForExistingProject } from "../../packageManager.js";
|
|
14
9
|
const URL_PREFIX = "https://raw.githubusercontent.com/IsaacScript/isaacscript/main/packages/isaacscript-cli/file-templates";
|
|
15
10
|
const MARKER_CUSTOMIZATION_START = "@template-customization-start";
|
|
16
11
|
const MARKER_CUSTOMIZATION_END = "@template-customization-end";
|
|
@@ -21,62 +16,63 @@ const PACKAGE_MANAGER_STRINGS = [
|
|
|
21
16
|
"PACKAGE_MANAGER_NAME",
|
|
22
17
|
"PACKAGE_MANAGER_INSTALL_COMMAND",
|
|
23
18
|
"PACKAGE_MANAGER_LOCK_FILE_NAME",
|
|
24
|
-
...
|
|
25
|
-
...
|
|
19
|
+
...getEnumValues(PackageManager),
|
|
20
|
+
...PACKAGE_MANAGER_LOCK_FILE_NAMES,
|
|
26
21
|
];
|
|
27
|
-
function check(args, typeScript) {
|
|
22
|
+
export function check(args, typeScript) {
|
|
28
23
|
const ignore = args.ignore ?? "";
|
|
29
24
|
const verbose = args.verbose === true;
|
|
25
|
+
const packageManager = getPackageManagerUsedForExistingProject(args);
|
|
30
26
|
let oneOrMoreErrors = false;
|
|
31
27
|
const ignoreFileNames = ignore.split(",");
|
|
32
|
-
const ignoreFileNamesSet = new
|
|
28
|
+
const ignoreFileNamesSet = new ReadonlySet(ignoreFileNames);
|
|
33
29
|
// First, check the static files that are shared between TypeScript projects and IsaacScript mods.
|
|
34
|
-
if (checkTemplateDirectory(
|
|
30
|
+
if (checkTemplateDirectory(TEMPLATES_STATIC_DIR, ignoreFileNamesSet, verbose)) {
|
|
35
31
|
oneOrMoreErrors = true;
|
|
36
32
|
}
|
|
37
33
|
// Second, check the files that are specific to either a TypeScript project or an IsaacScript mod.
|
|
38
34
|
const staticDirSuffix = typeScript ? "ts" : "mod";
|
|
39
|
-
const staticDirPath =
|
|
35
|
+
const staticDirPath = path.join(TEMPLATES_DIR, `static-${staticDirSuffix}`);
|
|
40
36
|
if (checkTemplateDirectory(staticDirPath, ignoreFileNamesSet, verbose)) {
|
|
41
37
|
oneOrMoreErrors = true;
|
|
42
38
|
}
|
|
43
|
-
|
|
39
|
+
// Third, check dynamic files that require specific logic.
|
|
40
|
+
if (checkIndividualFiles(ignoreFileNamesSet, packageManager, verbose)) {
|
|
44
41
|
oneOrMoreErrors = true;
|
|
45
42
|
}
|
|
46
43
|
if (oneOrMoreErrors) {
|
|
47
|
-
|
|
44
|
+
fatalError("The check command failed.");
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
|
-
exports.check = check;
|
|
51
47
|
function checkTemplateDirectory(templateDirectory, ignoreFileNamesSet, verbose) {
|
|
52
48
|
let oneOrMoreErrors = false;
|
|
53
|
-
for (const klawItem of (
|
|
49
|
+
for (const klawItem of klawSync(templateDirectory)) {
|
|
54
50
|
const templateFilePath = klawItem.path;
|
|
55
|
-
if ((
|
|
51
|
+
if (isDirectory(templateFilePath)) {
|
|
56
52
|
continue;
|
|
57
53
|
}
|
|
58
|
-
const originalFileName =
|
|
54
|
+
const originalFileName = path.basename(templateFilePath);
|
|
59
55
|
if (originalFileName === "main.ts") {
|
|
60
56
|
continue;
|
|
61
57
|
}
|
|
62
|
-
const relativeTemplateFilePath =
|
|
63
|
-
const templateFileName =
|
|
64
|
-
let projectFilePath =
|
|
58
|
+
const relativeTemplateFilePath = path.relative(templateDirectory, templateFilePath);
|
|
59
|
+
const templateFileName = path.basename(relativeTemplateFilePath);
|
|
60
|
+
let projectFilePath = path.join(CWD, relativeTemplateFilePath);
|
|
65
61
|
switch (templateFileName) {
|
|
66
62
|
case "_eslintrc.cjs": {
|
|
67
|
-
projectFilePath =
|
|
63
|
+
projectFilePath = path.join(projectFilePath, "..", ".eslintrc.cjs");
|
|
68
64
|
break;
|
|
69
65
|
}
|
|
70
|
-
case "_cspell.
|
|
71
|
-
projectFilePath =
|
|
66
|
+
case "_cspell.jsonc": {
|
|
67
|
+
projectFilePath = path.join(projectFilePath, "..", "cspell.jsonc");
|
|
72
68
|
break;
|
|
73
69
|
}
|
|
74
70
|
case "_gitattributes": {
|
|
75
|
-
projectFilePath =
|
|
71
|
+
projectFilePath = path.join(projectFilePath, "..", ".gitattributes");
|
|
76
72
|
break;
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
|
-
const projectFileName =
|
|
75
|
+
const projectFileName = path.basename(projectFilePath);
|
|
80
76
|
if (ignoreFileNamesSet.has(projectFileName)) {
|
|
81
77
|
continue;
|
|
82
78
|
}
|
|
@@ -86,12 +82,21 @@ function checkTemplateDirectory(templateDirectory, ignoreFileNamesSet, verbose)
|
|
|
86
82
|
}
|
|
87
83
|
return oneOrMoreErrors;
|
|
88
84
|
}
|
|
89
|
-
function checkIndividualFiles(ignoreFileNamesSet, verbose) {
|
|
85
|
+
function checkIndividualFiles(ignoreFileNamesSet, packageManager, verbose) {
|
|
90
86
|
let oneOrMoreErrors = false;
|
|
91
|
-
if (!ignoreFileNamesSet.has(
|
|
92
|
-
const templateFilePath =
|
|
93
|
-
const relativeTemplateFilePath =
|
|
94
|
-
const projectFilePath =
|
|
87
|
+
if (!ignoreFileNamesSet.has(ACTION_YML)) {
|
|
88
|
+
const templateFilePath = ACTION_YML_TEMPLATE_PATH;
|
|
89
|
+
const relativeTemplateFilePath = path.relative(TEMPLATES_DYNAMIC_DIR, templateFilePath);
|
|
90
|
+
const projectFilePath = path.join(CWD, relativeTemplateFilePath);
|
|
91
|
+
if (!compareTextFiles(projectFilePath, templateFilePath, verbose)) {
|
|
92
|
+
oneOrMoreErrors = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (packageManager === PackageManager.yarn &&
|
|
96
|
+
!ignoreFileNamesSet.has(YARNRC_YML)) {
|
|
97
|
+
const templateFilePath = YARNRC_TEMPLATE_PATH;
|
|
98
|
+
const relativeTemplateFilePath = path.relative(TEMPLATES_DYNAMIC_DIR, templateFilePath);
|
|
99
|
+
const projectFilePath = path.join(CWD, relativeTemplateFilePath);
|
|
95
100
|
if (!compareTextFiles(projectFilePath, templateFilePath, verbose)) {
|
|
96
101
|
oneOrMoreErrors = true;
|
|
97
102
|
}
|
|
@@ -100,21 +105,21 @@ function checkIndividualFiles(ignoreFileNamesSet, verbose) {
|
|
|
100
105
|
}
|
|
101
106
|
/** @returns Whether the project file is valid in reference to the template file. */
|
|
102
107
|
function compareTextFiles(projectFilePath, templateFilePath, verbose) {
|
|
103
|
-
if (!(
|
|
108
|
+
if (!isFile(projectFilePath)) {
|
|
104
109
|
console.log(`Failed to find the following file: ${projectFilePath}`);
|
|
105
110
|
printTemplateLocation(templateFilePath);
|
|
106
111
|
return false;
|
|
107
112
|
}
|
|
108
|
-
const projectFileObject = getTruncatedFileText(projectFilePath, new Set(), new Set()
|
|
109
|
-
const templateFileObject = getTruncatedFileText(templateFilePath, projectFileObject.ignoreLines, projectFileObject.linesBeforeIgnore
|
|
113
|
+
const projectFileObject = getTruncatedFileText(projectFilePath, new Set(), new Set());
|
|
114
|
+
const templateFileObject = getTruncatedFileText(templateFilePath, projectFileObject.ignoreLines, projectFileObject.linesBeforeIgnore);
|
|
110
115
|
if (projectFileObject.text === templateFileObject.text) {
|
|
111
116
|
return true;
|
|
112
117
|
}
|
|
113
|
-
console.log(`The contents of the following file do not match: ${
|
|
118
|
+
console.log(`The contents of the following file do not match: ${chalk.red(projectFilePath)}`);
|
|
114
119
|
printTemplateLocation(templateFilePath);
|
|
115
120
|
if (verbose) {
|
|
116
|
-
const originalTemplateFile =
|
|
117
|
-
const originalProjectFile =
|
|
121
|
+
const originalTemplateFile = readFile(templateFilePath);
|
|
122
|
+
const originalProjectFile = readFile(projectFilePath);
|
|
118
123
|
console.log("--- Original template file: ---\n");
|
|
119
124
|
console.log(originalTemplateFile);
|
|
120
125
|
console.log();
|
|
@@ -128,19 +133,19 @@ function compareTextFiles(projectFilePath, templateFilePath, verbose) {
|
|
|
128
133
|
console.log(projectFileObject.text);
|
|
129
134
|
console.log();
|
|
130
135
|
}
|
|
131
|
-
const tempProjectFilePath =
|
|
132
|
-
const tempTemplateFilePath =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const { stdout } =
|
|
136
|
+
const tempProjectFilePath = path.join(CWD, "tempProjectFile.txt");
|
|
137
|
+
const tempTemplateFilePath = path.join(CWD, "tempTemplateFile.txt");
|
|
138
|
+
writeFile(tempProjectFilePath, projectFileObject.text);
|
|
139
|
+
writeFile(tempTemplateFilePath, templateFileObject.text);
|
|
140
|
+
const { stdout } = execShell("diff", [tempProjectFilePath, tempTemplateFilePath, "--ignore-blank-lines"], verbose, true);
|
|
136
141
|
console.log(`${stdout}\n`);
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
deleteFileOrDirectory(tempProjectFilePath);
|
|
143
|
+
deleteFileOrDirectory(tempTemplateFilePath);
|
|
139
144
|
return false;
|
|
140
145
|
}
|
|
141
|
-
function getTruncatedFileText(filePath, ignoreLines, linesBeforeIgnore
|
|
142
|
-
const fileName =
|
|
143
|
-
const fileContents =
|
|
146
|
+
function getTruncatedFileText(filePath, ignoreLines, linesBeforeIgnore) {
|
|
147
|
+
const fileName = path.basename(filePath);
|
|
148
|
+
const fileContents = readFile(filePath);
|
|
144
149
|
return getTruncatedText(fileName, fileContents, ignoreLines, linesBeforeIgnore);
|
|
145
150
|
}
|
|
146
151
|
/**
|
|
@@ -152,7 +157,7 @@ function getTruncatedFileText(filePath, ignoreLines, linesBeforeIgnore, verbose)
|
|
|
152
157
|
* markers (and other specific hard-coded exclusions), as well as an array of lines that
|
|
153
158
|
* had a "ignore-next-line" marker below them.
|
|
154
159
|
*/
|
|
155
|
-
function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
|
|
160
|
+
export function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
|
|
156
161
|
const lines = text.split("\n");
|
|
157
162
|
const newLines = [];
|
|
158
163
|
const newIgnoreLines = new Set();
|
|
@@ -201,7 +206,7 @@ function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
|
|
|
201
206
|
continue;
|
|
202
207
|
}
|
|
203
208
|
if (isIgnoring) {
|
|
204
|
-
const baseLine =
|
|
209
|
+
const baseLine = trimPrefix(line.trim(), "// ");
|
|
205
210
|
newIgnoreLines.add(baseLine);
|
|
206
211
|
continue;
|
|
207
212
|
}
|
|
@@ -209,7 +214,7 @@ function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
|
|
|
209
214
|
// Specific file checks
|
|
210
215
|
// --------------------
|
|
211
216
|
// End-users can have different ignored words.
|
|
212
|
-
if (fileName === "cspell.
|
|
217
|
+
if (fileName === "cspell.jsonc" || fileName === "_cspell.jsonc") {
|
|
213
218
|
if (line.match(/"words": \[.*]/) !== null) {
|
|
214
219
|
continue;
|
|
215
220
|
}
|
|
@@ -222,12 +227,12 @@ function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
|
|
|
222
227
|
continue;
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
|
-
if (fileName === "ci.yml") {
|
|
230
|
+
if (fileName === "ci.yml" || fileName === "action.yml") {
|
|
226
231
|
// End-users can have different package managers.
|
|
227
232
|
if (hasPackageManagerString(line)) {
|
|
228
233
|
continue;
|
|
229
234
|
}
|
|
230
|
-
// Ignore comments, since end-users are expected to delete the
|
|
235
|
+
// Ignore comments, since end-users are expected to delete the explanations.
|
|
231
236
|
if (line.match(/^\s*#/) !== null) {
|
|
232
237
|
continue;
|
|
233
238
|
}
|
|
@@ -247,17 +252,15 @@ function getTruncatedText(fileName, text, ignoreLines, linesBeforeIgnore) {
|
|
|
247
252
|
linesBeforeIgnore: newLinesBeforeIgnore,
|
|
248
253
|
};
|
|
249
254
|
}
|
|
250
|
-
exports.getTruncatedText = getTruncatedText;
|
|
251
255
|
function printTemplateLocation(templateFilePath) {
|
|
252
|
-
const unixPath = templateFilePath.split(
|
|
256
|
+
const unixPath = templateFilePath.split(path.sep).join(path.posix.sep);
|
|
253
257
|
const match = unixPath.match(/.+\/file-templates\/(?<urlSuffix>.+)/);
|
|
254
258
|
if (match === null || match.groups === undefined) {
|
|
255
|
-
|
|
259
|
+
fatalError(`Failed to parse the template file path: ${templateFilePath}`);
|
|
256
260
|
}
|
|
257
261
|
const { urlSuffix } = match.groups;
|
|
258
|
-
console.log(`You can find the template at: ${
|
|
262
|
+
console.log(`You can find the template at: ${chalk.green(`${URL_PREFIX}/${urlSuffix}`)}\n`);
|
|
259
263
|
}
|
|
260
264
|
function hasPackageManagerString(line) {
|
|
261
265
|
return PACKAGE_MANAGER_STRINGS.some((string) => line.includes(string));
|
|
262
266
|
}
|
|
263
|
-
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { strictEqual } from "node:assert";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { getTruncatedText } from "./check.js";
|
|
4
|
+
test("no markers", () => {
|
|
5
|
+
const templateText = `
|
|
6
|
+
line 1
|
|
7
|
+
line 2
|
|
8
|
+
line 3
|
|
9
|
+
`.trim();
|
|
10
|
+
const { text } = getTruncatedText("test", templateText, new Set(), new Set());
|
|
11
|
+
strictEqual(text, templateText);
|
|
12
|
+
});
|
|
13
|
+
test("customization marker", () => {
|
|
14
|
+
const templateText = `
|
|
15
|
+
line 1
|
|
16
|
+
@template-customization-start
|
|
17
|
+
line 2
|
|
18
|
+
@template-customization-end
|
|
19
|
+
line 3
|
|
20
|
+
`.trim();
|
|
21
|
+
const expectedTemplateText = `
|
|
22
|
+
line 1
|
|
23
|
+
line 3
|
|
24
|
+
`.trim();
|
|
25
|
+
const { text } = getTruncatedText("test", templateText, new Set(), new Set());
|
|
26
|
+
strictEqual(text, expectedTemplateText);
|
|
27
|
+
});
|
|
28
|
+
test("ignore block marker part 1", () => {
|
|
29
|
+
const templateText = `
|
|
30
|
+
line 1
|
|
31
|
+
@template-ignore-block-start
|
|
32
|
+
// line 2
|
|
33
|
+
@template-ignore-block-end
|
|
34
|
+
line 3
|
|
35
|
+
`.trim();
|
|
36
|
+
const parsedTemplateText = `
|
|
37
|
+
line 1
|
|
38
|
+
line 3
|
|
39
|
+
`.trim();
|
|
40
|
+
const { text, ignoreLines } = getTruncatedText("test", templateText, new Set(), new Set());
|
|
41
|
+
strictEqual(text, parsedTemplateText);
|
|
42
|
+
strictEqual(ignoreLines.size, 1);
|
|
43
|
+
strictEqual([...ignoreLines][0], "line 2");
|
|
44
|
+
});
|
|
45
|
+
test("ignore block marker part 2", () => {
|
|
46
|
+
const templateText = `
|
|
47
|
+
line 1
|
|
48
|
+
line 2
|
|
49
|
+
line 3
|
|
50
|
+
`.trim();
|
|
51
|
+
const expectedTemplateText = `
|
|
52
|
+
line 1
|
|
53
|
+
line 3
|
|
54
|
+
`.trim();
|
|
55
|
+
const { text } = getTruncatedText("test", templateText, new Set(["line 2"]), new Set());
|
|
56
|
+
strictEqual(text, expectedTemplateText);
|
|
57
|
+
});
|
|
58
|
+
test("ignore next line part 1", () => {
|
|
59
|
+
const templateText = `
|
|
60
|
+
line 1
|
|
61
|
+
@template-ignore-next-line
|
|
62
|
+
line 2
|
|
63
|
+
line 3
|
|
64
|
+
`.trim();
|
|
65
|
+
const expectedTemplateText = `
|
|
66
|
+
line 1
|
|
67
|
+
line 3
|
|
68
|
+
`.trim();
|
|
69
|
+
const { text, linesBeforeIgnore } = getTruncatedText("test", templateText, new Set(), new Set());
|
|
70
|
+
strictEqual(linesBeforeIgnore.size, 1);
|
|
71
|
+
strictEqual([...linesBeforeIgnore][0], "line 1");
|
|
72
|
+
strictEqual(text, expectedTemplateText);
|
|
73
|
+
});
|
|
74
|
+
test("ignore next line part 2", () => {
|
|
75
|
+
const templateText = `
|
|
76
|
+
line 1
|
|
77
|
+
line 2
|
|
78
|
+
line 3
|
|
79
|
+
`.trim();
|
|
80
|
+
const expectedTemplateText = `
|
|
81
|
+
line 1
|
|
82
|
+
line 3
|
|
83
|
+
`.trim();
|
|
84
|
+
const { text } = getTruncatedText("test", templateText, new Set(), new Set(["line 1"]));
|
|
85
|
+
strictEqual(text, expectedTemplateText);
|
|
86
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { copyFileOrDirectory, deleteFileOrDirectory, getPackageManagerExecCommand, } from "isaacscript-common-node";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { MOD_SOURCE_PATH } from "../../constants.js";
|
|
4
|
+
import { prepareCustomStages } from "../../customStage.js";
|
|
5
|
+
import { execShellString } from "../../exec.js";
|
|
6
|
+
import { getPackageManagerUsedForExistingProject } from "../../packageManager.js";
|
|
7
|
+
import { getModTargetDirectoryName } from "../../utils.js";
|
|
8
|
+
export async function copy(args, config) {
|
|
9
|
+
const verbose = args.verbose === true;
|
|
10
|
+
const packageManager = getPackageManagerUsedForExistingProject(args);
|
|
11
|
+
const modTargetDirectoryName = getModTargetDirectoryName(config);
|
|
12
|
+
const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
|
|
13
|
+
await compileAndCopy(MOD_SOURCE_PATH, modTargetPath, packageManager, verbose);
|
|
14
|
+
}
|
|
15
|
+
export async function compileAndCopy(modSourcePath, modTargetPath, packageManager, verbose) {
|
|
16
|
+
await prepareCustomStages(packageManager, verbose);
|
|
17
|
+
compile(packageManager, verbose);
|
|
18
|
+
copyMod(modSourcePath, modTargetPath);
|
|
19
|
+
}
|
|
20
|
+
function compile(packageManager, verbose) {
|
|
21
|
+
const command = getPackageManagerExecCommand(packageManager);
|
|
22
|
+
execShellString(`${command} tstl`, verbose);
|
|
23
|
+
console.log("Mod compiled successfully.");
|
|
24
|
+
}
|
|
25
|
+
function copyMod(modSourcePath, modTargetPath) {
|
|
26
|
+
deleteFileOrDirectory(modTargetPath);
|
|
27
|
+
copyFileOrDirectory(modSourcePath, modTargetPath);
|
|
28
|
+
console.log("Mod copied successfully.");
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { deleteFileOrDirectory, fatalError, fileOrDirectoryExists, isDirectory, } from "isaacscript-common-node";
|
|
3
|
+
import { CWD } from "../../constants.js";
|
|
4
|
+
import { getInputYesNo } from "../../prompt.js";
|
|
5
|
+
export async function checkIfProjectPathExists(projectPath, yes) {
|
|
6
|
+
if (projectPath === CWD || !fileOrDirectoryExists(projectPath)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const fileType = isDirectory(projectPath) ? "directory" : "file";
|
|
10
|
+
if (yes) {
|
|
11
|
+
deleteFileOrDirectory(projectPath);
|
|
12
|
+
console.log(`Deleted ${fileType}: ${chalk.green(projectPath)}`);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
console.log(`A ${fileType} already exists with a name of: ${chalk.green(projectPath)}`);
|
|
16
|
+
const shouldDelete = await getInputYesNo("Do you want me to delete it?");
|
|
17
|
+
if (!shouldDelete) {
|
|
18
|
+
fatalError("Ok then. Goodbye.");
|
|
19
|
+
}
|
|
20
|
+
deleteFileOrDirectory(projectPath);
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { fatalError, isSubdirectoryOf } from "isaacscript-common-node";
|
|
3
|
+
import { CWD } from "../../constants.js";
|
|
4
|
+
export function checkModSubdirectory(projectPath, modsDirectory) {
|
|
5
|
+
if (isSubdirectoryOf(CWD, modsDirectory)) {
|
|
6
|
+
console.error(`Error: The project directory of "${chalk.green(projectPath)}" is a subdirectory of "${chalk.green(modsDirectory)}".`);
|
|
7
|
+
fatalError('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.');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { deleteFileOrDirectory, fatalError, fileOrDirectoryExists, isDirectory, } from "isaacscript-common-node";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { PROJECT_NAME } from "../../constants.js";
|
|
5
|
+
import { getInputYesNo } from "../../prompt.js";
|
|
6
|
+
export async function checkModTargetDirectory(modsDirectory, projectName, yes) {
|
|
7
|
+
const modTargetPath = path.join(modsDirectory, projectName);
|
|
8
|
+
if (!fileOrDirectoryExists(modTargetPath)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const fileType = isDirectory(modTargetPath) ? "directory" : "file";
|
|
12
|
+
if (yes) {
|
|
13
|
+
deleteFileOrDirectory(modTargetPath);
|
|
14
|
+
console.log(`Deleted ${fileType}: ${chalk.green(modTargetPath)}`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
console.log(`A ${fileType} already exists at at the mod path of: ${chalk.green(modTargetPath)}`);
|
|
18
|
+
console.log(`${PROJECT_NAME} will need to sync your project folder with this directory.`);
|
|
19
|
+
const shouldDelete = await getInputYesNo("Do you want me to delete it?");
|
|
20
|
+
if (!shouldDelete) {
|
|
21
|
+
fatalError("Ok then. Goodbye.");
|
|
22
|
+
}
|
|
23
|
+
deleteFileOrDirectory(modTargetPath);
|
|
24
|
+
}
|