Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit375e843

Browse files
authored
fix(cli): preserve intermediate directories when resolving nested file paths (#1607)
Fixes component installation paths for custom registries with additionalpath levels. Previously, only the last segment of the common root waspreserved, causing intermediate directories to be lost.Example:- Before: components/ai-elements/artifact/Artifact.vue → artifact/Artifact.vue- After: components/ai-elements/artifact/Artifact.vue → ai-elements/artifact/Artifact.vueThe function now uses the component alias from config to correctly resolvepaths for any custom registry structure, not just the default "components"directory.
1 parent52a687f commit375e843

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎packages/cli/src/utils/updaters/update-files.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export function resolveFilePath(
357357

358358
consttargetDir=resolveFileTargetDirectory(file,config)
359359

360-
constrelativePath=resolveNestedFilePath(file.path,options.commonRoot)
360+
constrelativePath=resolveNestedFilePath(file.path,options.commonRoot,config)
361361
returnpath.join(targetDir!,relativePath)
362362
}
363363

@@ -419,11 +419,28 @@ export function findCommonRoot(paths: string[], needle: string): string {
419419
exportfunctionresolveNestedFilePath(
420420
filePath:string,
421421
commonRoot:string,
422+
config:Config,
422423
):string{
423424
// Normalize paths by removing leading/trailing slashes
424425
constnormalizedFilePath=filePath.replace(/^\/|\/$/g,'')
425426
constnormalizedCommonRoot=commonRoot.replace(/^\/|\/$/g,'')
426427

428+
// Get component alias without @ prefix and normalize
429+
constcomponentAlias=config.aliases.components.replace(/^@\//,'').replace(/^\/|\/$/g,'')
430+
431+
// Check if the common root contains the component alias
432+
if(normalizedCommonRoot.includes(componentAlias)){
433+
// Find where the component alias ends in the file path
434+
constaliasEndIndex=normalizedFilePath.indexOf(componentAlias)+componentAlias.length
435+
436+
// Return everything after the alias (skip the leading slash if present)
437+
// Example: "components/ai-elements/artifact/Artifact.vue" -> "ai-elements/artifact/Artifact.vue"
438+
// Example: "src/ui/design-system/button/Button.vue" -> "design-system/button/Button.vue"
439+
returnnormalizedFilePath.substring(aliasEndIndex).replace(/^\//,'')
440+
}
441+
442+
// Fallback to original logic for non-component paths
443+
// Example: "registry/new-york-v4/ui/button/Button.vue" -> "button/Button.vue"
427444
constlastCommonRootSegment=normalizedCommonRoot.split('/').pop()
428445

429446
// normalizedFilePath: registry/new-york-v4/ui/button/Button.vue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp