The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
rollback
vholikdcf66e1bcbd7
diff --git a/packages/cli/src/utils/file-type.ts b/packages/cli/src/utils/file-type.tsindex f63e4522a..470d53430 100644--- a/packages/cli/src/utils/file-type.ts+++ b/packages/cli/src/utils/file-type.ts@@ -27,27 +27,3 @@ export function getRelativePath(filePath: string) {);}-/**- * Resolve nested file path by finding the common root between file path and target directory.- */-export function resolveNestedFilePath(filePath: string, targetDir: string) {- const fileName = filePath.split("/").pop() || filePath;-- // Get path segments- const fileSegments = filePath.split("/").slice(0, -1); // Remove filename- const targetSegments = targetDir.split("/");-- // Find common segments from the end of targetDir matching start of filePath- let commonLength = 0;- for (let i = 0; i < fileSegments.length && i < targetSegments.length; i++) {- const targetEnd = targetSegments.slice(-(i + 1)).join("/");- const fileStart = fileSegments.slice(0, i + 1).join("/");- if (targetEnd === fileStart) {- commonLength = i + 1;- }- }-- // Build relative path from non-common segments- const relativeParts = fileSegments.slice(commonLength);- return [...relativeParts, fileName].join("/");-}diff --git a/packages/cli/src/utils/update-files.ts b/packages/cli/src/utils/update-files.tsindex c52bb8378..1c8b5f2ae 100644--- a/packages/cli/src/utils/update-files.ts+++ b/packages/cli/src/utils/update-files.ts@@ -5,7 +5,7 @@ import prompts from "prompts";import type { RegistryItem } from "../registry/schema";import type { Config } from "../schema";import { isContentSame } from "./compare";-import { getTargetDir, resolveNestedFilePath } from "./file-type";+import { getRelativePath, getTargetDir } from "./file-type";import { getProjectInfo } from "./get-project-info";import { highlighter } from "./highlighter";import { logger } from "./logger";@@ -51,43 +51,18 @@ export async function updateFiles(for (const file of files) {const fileType = getTargetDir(file);- const targetDir = config.resolvedPaths[fileType];+ const relativePath = file.target ?? getRelativePath(file.path);+ const basePath = options.path || config.resolvedPaths[fileType];- let filePath: string;+ let filePath = path.resolve(basePath, relativePath);- // Handle custom path option- if (options.path) {- const resolvedPath = path.isAbsolute(options.path)- ? options.path- : path.join(config.resolvedPaths.cwd, options.path);- const fileName = path.basename(file.path);- filePath = path.join(resolvedPath, fileName);- }- // Handle file.target with ~/ prefix (relative to cwd)- else if (file.target?.startsWith("~/")) {- filePath = path.join(- config.resolvedPaths.cwd,- file.target.replace("~/", "")- );- }- // Handle explicit file.target- else if (file.target) {- filePath = projectInfo?.isSrcDir- ? path.join(- config.resolvedPaths.cwd,- "src",- file.target.replace("src/", "")- )- : path.join(config.resolvedPaths.cwd, file.target.replace("src/", ""));- }- // Default: resolve nested path within target directory- else {- const relativePath = resolveNestedFilePath(file.path, targetDir);- filePath = path.join(targetDir, relativePath);+ if (projectInfo?.isSrcDir && !filePath.includes("src")) {+ const srcPath = path.resolve(config.resolvedPaths.cwd, "src");+ filePath = path.resolve(srcPath, relativePath);}const fileName = basename(file.path);- const fileDir = path.dirname(filePath);+ const targetDir = path.dirname(filePath);const existingFile = existsSync(filePath);@@ -99,7 +74,7 @@ export async function updateFiles(const content = await transformImports({filename: file.path,- raw: file.content ?? "",+ raw: file.content,config,isRemote: false,});@@ -135,8 +110,8 @@ export async function updateFiles(}}- if (!existsSync(fileDir)) {- await fs.mkdir(fileDir, { recursive: true });+ if (!existsSync(targetDir)) {+ await fs.mkdir(targetDir, { recursive: true });}await fs.writeFile(filePath, content, "utf-8");@@ -316,4 +291,4 @@ function printDiff(diff: Change[]) {process.stdout.write(`${line}\n`);}}-}+}\ No newline at end of file