Fix Turbopack module resolution for lzma and restore path imports
This commit is contained in:
1 parent
a5044c80d7
commit
e06596391e
35 files changed
+392
-333
No files matched your search
@@ -38,6 +38,7 @@ import {
|
||||
extractIconFromSwfAsync,
|
||||
parseNitroBundle,
|
||||
} from "@/lib/services/swf-to-nitro";
|
||||
import { getRuntimePath } from "@/lib/utils/runtime-path";
|
||||
import type { ImportSingleResult } from "@/types/furni";
|
||||
|
||||
// Re-export the download helpers now owned by the shared import core.
|
||||
@@ -95,7 +96,7 @@ async function mirrorFileToDirs(
|
||||
if (!existsSync(/*turbopackIgnore: true*/ sourcePath)) return;
|
||||
|
||||
for (const dir of dirs) {
|
||||
const targetPath = path.join(/*turbopackIgnore: true*/ dir, fileName);
|
||||
const targetPath = getRuntimePath(/*turbopackIgnore: true*/ dir, fileName);
|
||||
const sourceKey =
|
||||
process.platform === "win32" ? sourcePath.toLowerCase() : sourcePath;
|
||||
const targetKey =
|
||||
@@ -362,10 +363,10 @@ async function copyIfMissing(
|
||||
entry: string,
|
||||
copied: string[],
|
||||
): Promise<void> {
|
||||
const dest = path.join(targetDir, entry);
|
||||
const dest = getRuntimePath(targetDir, entry);
|
||||
if (existsSync(dest)) return;
|
||||
try {
|
||||
await fs.copyFile(path.join(sourceDir, entry), dest);
|
||||
await fs.copyFile(getRuntimePath(sourceDir, entry), dest);
|
||||
copied.push(entry);
|
||||
} catch (err) {
|
||||
logger.warn("[import-furni] gamedata bundle sync copy failed", {
|
||||
@@ -423,7 +424,10 @@ export async function syncAssetsToGamedataBundle(): Promise<{
|
||||
const copiedNitros: string[] = [];
|
||||
const copiedIcons: string[] = [];
|
||||
|
||||
const nitroTarget = path.join(gamedataRoot, "bundled/furniture");
|
||||
const nitroTarget = /*turbopackIgnore: true*/ getRuntimePath(
|
||||
gamedataRoot,
|
||||
"bundled/furniture",
|
||||
);
|
||||
if (nitroDir !== nitroTarget) {
|
||||
const copied = await syncDirMissingFiles(nitroDir, nitroTarget, (entry) =>
|
||||
entry.endsWith(".nitro"),
|
||||
@@ -431,7 +435,10 @@ export async function syncAssetsToGamedataBundle(): Promise<{
|
||||
copiedNitros.push(...copied);
|
||||
}
|
||||
|
||||
const iconTarget = path.join(gamedataRoot, "icons");
|
||||
const iconTarget = /*turbopackIgnore: true*/ getRuntimePath(
|
||||
gamedataRoot,
|
||||
"icons",
|
||||
);
|
||||
if (iconDir !== iconTarget) {
|
||||
const copied = await syncDirMissingFiles(iconDir, iconTarget, (entry) =>
|
||||
entry.endsWith("_icon.png"),
|
||||
@@ -680,15 +687,15 @@ export async function importSingleFurni(params: {
|
||||
const iconFileName = classname.replace(/\*/g, "_");
|
||||
const safeSwfName = baseClassname;
|
||||
const safeNitroName = baseClassname;
|
||||
const swfPath = path.join(
|
||||
const swfPath = getRuntimePath(
|
||||
/*turbopackIgnore: true*/ swfDir,
|
||||
`${safeSwfName}.swf`,
|
||||
);
|
||||
const nitroPath = path.join(
|
||||
const nitroPath = getRuntimePath(
|
||||
/*turbopackIgnore: true*/ nitroDir,
|
||||
`${safeNitroName}.nitro`,
|
||||
);
|
||||
const iconPath = path.join(
|
||||
const iconPath = getRuntimePath(
|
||||
/*turbopackIgnore: true*/ iconDir,
|
||||
`${iconFileName}_icon.png`,
|
||||
);
|
||||
@@ -1092,7 +1099,7 @@ async function realNitroModes(classname: string): Promise<number | undefined> {
|
||||
const cached = nitroModesCache.get(base);
|
||||
if (cached !== undefined) return cached;
|
||||
try {
|
||||
const nitroPath = path.join(
|
||||
const nitroPath = getRuntimePath(
|
||||
/*turbopackIgnore: true*/ FURNI_NITRO_DIR,
|
||||
`${base}.nitro`,
|
||||
);
|
||||
@@ -1317,16 +1324,25 @@ export async function deleteImportedItem(classname: string): Promise<{
|
||||
|
||||
// 4. Delete files (.nitro, .swf, icon)
|
||||
const filesToDelete = [
|
||||
path.join(/*turbopackIgnore: true*/ nitroDir, `${baseClassname}.nitro`),
|
||||
path.join(/*turbopackIgnore: true*/ swfDir, `${baseClassname}.swf`),
|
||||
path.join(/*turbopackIgnore: true*/ iconDir, `${iconFileName}_icon.png`),
|
||||
getRuntimePath(
|
||||
/*turbopackIgnore: true*/ nitroDir,
|
||||
`${baseClassname}.nitro`,
|
||||
),
|
||||
getRuntimePath(/*turbopackIgnore: true*/ swfDir, `${baseClassname}.swf`),
|
||||
getRuntimePath(
|
||||
/*turbopackIgnore: true*/ iconDir,
|
||||
`${iconFileName}_icon.png`,
|
||||
),
|
||||
...assetTargets.mirrorDirs.flatMap((dirs) => [
|
||||
path.join(
|
||||
getRuntimePath(
|
||||
/*turbopackIgnore: true*/ dirs.nitroDir,
|
||||
`${baseClassname}.nitro`,
|
||||
),
|
||||
path.join(/*turbopackIgnore: true*/ dirs.swfDir, `${baseClassname}.swf`),
|
||||
path.join(
|
||||
getRuntimePath(
|
||||
/*turbopackIgnore: true*/ dirs.swfDir,
|
||||
`${baseClassname}.swf`,
|
||||
),
|
||||
getRuntimePath(
|
||||
/*turbopackIgnore: true*/ dirs.iconDir,
|
||||
`${iconFileName}_icon.png`,
|
||||
),
|
||||
@@ -1366,14 +1382,16 @@ export async function cleanupConvertedSwfs(): Promise<{
|
||||
|
||||
for (const swfFile of swfFiles) {
|
||||
const cn = swfFile.replace(".swf", "");
|
||||
const nitroFilePath = path.join(
|
||||
const nitroFilePath = getRuntimePath(
|
||||
/*turbopackIgnore: true*/ nitroDir,
|
||||
`${cn}.nitro`,
|
||||
);
|
||||
|
||||
if (existsSync(/*turbopackIgnore: true*/ nitroFilePath)) {
|
||||
try {
|
||||
await fs.unlink(path.join(/*turbopackIgnore: true*/ swfDir, swfFile));
|
||||
await fs.unlink(
|
||||
getRuntimePath(/*turbopackIgnore: true*/ swfDir, swfFile),
|
||||
);
|
||||
deleted++;
|
||||
} catch (err) {
|
||||
errors.push(`Failed to delete ${swfFile}: ${(err as Error).message}`);
|
||||
@@ -1513,13 +1531,16 @@ export async function rollbackFurniImport(
|
||||
|
||||
// 4. Delete asset files
|
||||
const filesToDelete = [
|
||||
path.join(nitroDir, `${base}.nitro`),
|
||||
path.join(swfDir, `${base}.swf`),
|
||||
path.join(iconDir, `${classname.replace(/\*/g, "_")}_icon.png`),
|
||||
/*turbopackIgnore: true*/ getRuntimePath(nitroDir, `${base}.nitro`),
|
||||
getRuntimePath(swfDir, `${base}.swf`),
|
||||
/*turbopackIgnore: true*/ getRuntimePath(
|
||||
iconDir,
|
||||
`${classname.replace(/\*/g, "_")}_icon.png`,
|
||||
),
|
||||
];
|
||||
|
||||
for (const filePath of filesToDelete) {
|
||||
if (existsSync(filePath)) {
|
||||
if (existsSync(/*turbopackIgnore: true*/ filePath)) {
|
||||
try {
|
||||
await fs.unlink(filePath);
|
||||
} catch (err) {
|
||||
@@ -1533,11 +1554,17 @@ export async function rollbackFurniImport(
|
||||
// Mirror directories
|
||||
for (const dirs of assetTargets.mirrorDirs) {
|
||||
for (const filePath of [
|
||||
path.join(dirs.nitroDir, `${classname.split("*")[0]}.nitro`),
|
||||
path.join(dirs.swfDir, `${classname.split("*")[0]}.swf`),
|
||||
path.join(dirs.iconDir, `${classname.replace(/\*/g, "_")}_icon.png`),
|
||||
/*turbopackIgnore: true*/ getRuntimePath(
|
||||
dirs.nitroDir,
|
||||
`${classname.split("*")[0]}.nitro`,
|
||||
),
|
||||
getRuntimePath(dirs.swfDir, `${classname.split("*")[0]}.swf`),
|
||||
/*turbopackIgnore: true*/ getRuntimePath(
|
||||
dirs.iconDir,
|
||||
`${classname.replace(/\*/g, "_")}_icon.png`,
|
||||
),
|
||||
]) {
|
||||
if (existsSync(filePath)) {
|
||||
if (existsSync(/*turbopackIgnore: true*/ filePath)) {
|
||||
try {
|
||||
await fs.unlink(filePath);
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user