Skip to content

Commit 12a603d

Browse files
committed
fix(cli): custom stage + isaacScriptCommonDev
1 parent 526025e commit 12a603d

7 files changed

Lines changed: 49 additions & 9 deletions

File tree

packages/isaacscript-cli/scripts/build.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function copyITDEnums(packageRoot: string) {
9090

9191
function copyITDEnumsFlag(packageRoot: string) {
9292
const sourcePackage = "isaac-typescript-definitions";
93-
const sourceDirectoryPath = path.join(
93+
const sourceDirectoryPath = path.resolve(
9494
packageRoot,
9595
"..",
9696
sourcePackage,
@@ -132,7 +132,7 @@ function copyITDEnumsFlag(packageRoot: string) {
132132

133133
function copyISCInterfaces(packageRoot: string) {
134134
const sourcePackage = "isaacscript-common";
135-
const sourceDirectoryPath = path.join(
135+
const sourceDirectoryPath = path.resolve(
136136
packageRoot,
137137
"..",
138138
sourcePackage,
@@ -176,7 +176,7 @@ function copyISCInterfaces(packageRoot: string) {
176176

177177
function copyISCObjects(packageRoot: string) {
178178
const sourcePackage = "isaacscript-common";
179-
const sourceDirectoryPath = path.join(
179+
const sourceDirectoryPath = path.resolve(
180180
packageRoot,
181181
"..",
182182
sourcePackage,

packages/isaacscript-cli/src/commands/check/check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function checkTemplateDirectory(
130130
}
131131

132132
case "_gitattributes": {
133-
projectFilePath = path.join(projectFilePath, "..", ".gitattributes");
133+
projectFilePath = path.resolve(projectFilePath, "..", ".gitattributes");
134134
break;
135135
}
136136

packages/isaacscript-cli/src/commands/copy/copy.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,23 @@ async function copy(options: CopyOptions) {
3535
const modTargetDirectoryName = getModTargetDirectoryName(config);
3636
const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
3737

38-
await compileAndCopy(MOD_SOURCE_PATH, modTargetPath, packageManager, verbose);
38+
await compileAndCopy(
39+
MOD_SOURCE_PATH,
40+
modTargetPath,
41+
packageManager,
42+
config.isaacScriptCommonDev,
43+
verbose,
44+
);
3945
}
4046

4147
export async function compileAndCopy(
4248
modSourcePath: string,
4349
modTargetPath: string,
4450
packageManager: PackageManager,
51+
isaacScriptCommonDev: boolean | undefined,
4552
verbose: boolean,
4653
): Promise<void> {
47-
await prepareCustomStages(packageManager, verbose);
54+
await prepareCustomStages(packageManager, isaacScriptCommonDev, verbose);
4855
compile(packageManager, verbose);
4956
copyMod(modSourcePath, modTargetPath);
5057
}

packages/isaacscript-cli/src/commands/monitor/monitor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ async function monitor(options: MonitorOptions) {
8484
}
8585

8686
// Prepare the custom stages feature, if necessary.
87-
await prepareCustomStages(packageManager, verbose);
87+
await prepareCustomStages(
88+
packageManager,
89+
config.isaacScriptCommonDev,
90+
verbose,
91+
);
8892

8993
// Delete and re-copy the mod every time IsaacScript starts. This ensures that it is always the
9094
// latest version.

packages/isaacscript-cli/src/commands/publish/isaacscriptMod.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ export async function publishIsaacScriptMod(
3333
const version = await getPackageJSONVersion(undefined);
3434

3535
runReleaseScriptPreCopy(verbose);
36-
await compileAndCopy(MOD_SOURCE_PATH, modTargetPath, packageManager, verbose);
36+
await compileAndCopy(
37+
MOD_SOURCE_PATH,
38+
modTargetPath,
39+
packageManager,
40+
config.isaacScriptCommonDev,
41+
verbose,
42+
);
3743
purgeRoomXMLs(modTargetPath);
3844
runReleaseScriptPostCopy(verbose);
3945

packages/isaacscript-cli/src/customStage.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const EMPTY_SHADER_NAME = "IsaacScript-RenderAboveHUD";
5353

5454
export async function prepareCustomStages(
5555
packageManager: PackageManager,
56+
isaacScriptCommonDev: boolean | undefined,
5657
verbose: boolean,
5758
): Promise<void> {
5859
const customStagesTSConfig = await getCustomStagesFromTSConfig();
@@ -64,7 +65,11 @@ export async function prepareCustomStages(
6465

6566
copyCustomStageFilesToProject();
6667
await insertEmptyShader();
67-
await fillCustomStageMetadata(customStagesTSConfig, packageManager);
68+
await fillCustomStageMetadata(
69+
customStagesTSConfig,
70+
packageManager,
71+
isaacScriptCommonDev,
72+
);
6873
combineCustomStageXMLs(customStagesTSConfig, verbose);
6974
}
7075

@@ -215,13 +220,31 @@ async function insertEmptyShader() {
215220
async function fillCustomStageMetadata(
216221
customStagesTSConfig: readonly CustomStageTSConfig[],
217222
packageManager: PackageManager,
223+
isaacScriptCommonDev: boolean | undefined,
218224
) {
219225
validateMetadataLuaFileExists(packageManager);
220226

221227
const customStages = await getCustomStagesWithMetadata(customStagesTSConfig);
222228
const customStagesLua = await convertCustomStagesToLua(customStages);
223229
writeFile(METADATA_LUA_PATH, customStagesLua);
224230
console.log(`Wrote custom stage metadata to: ${METADATA_LUA_PATH}`);
231+
232+
// In development, the "isaacscript-common" directory will be linked to the "isaacscript"
233+
// repository. However, even though the directory is soft-linked, writing to the above path will
234+
// not propagate it correctly. Thus, we must also explicitly write it to the development path.
235+
if (isaacScriptCommonDev === true) {
236+
const METADATA_LUA_PATH_DEV = path.resolve(
237+
CWD,
238+
"..",
239+
"isaacscript",
240+
"packages",
241+
"isaacscript-common",
242+
"dist",
243+
"customStageMetadata.lua",
244+
);
245+
writeFile(METADATA_LUA_PATH_DEV, customStagesLua);
246+
console.log(`Wrote custom stage metadata to: ${METADATA_LUA_PATH_DEV}`);
247+
}
225248
}
226249

227250
function validateMetadataLuaFileExists(packageManager: PackageManager) {

packages/isaacscript-common/yarn.lock

Whitespace-only changes.

0 commit comments

Comments
 (0)