diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5438a20..0a8a04a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,8 @@ on: branches: [ main ] # Trigger the workflow on any pull request pull_request: + # Allow manual trigger + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/backend/sources/impl/SvelteSource.kt b/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/backend/sources/impl/SvelteSource.kt index 9d86933..58be5a7 100644 --- a/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/backend/sources/impl/SvelteSource.kt +++ b/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/backend/sources/impl/SvelteSource.kt @@ -72,14 +72,27 @@ open class SvelteSource(project: Project) : Source(project, Svelte fileManager.getFileContentsAtPath(configFileName) ?: throw NoSuchFileException("Cannot get $configFileName after sync") } - val aliasPath = parseTsConfig(tsConfig) + // Handle scoped package aliases (e.g. @repo/ui/components). + // For @-prefixed aliases, the package name includes a slash (@scope/name), + // so we split into at most 3 parts to correctly separate the prefix from the rest. + val (aliasPrefix, suffix) = if (alias.startsWith("@")) { + val parts = alias.split("/", limit = 3) + val prefix = if (parts.size >= 2) "${parts[0]}/${parts[1]}" else alias + val rest = if (parts.size >= 3) parts[2] else "" + prefix to rest + } else { + alias.substringBefore("/") to alias.substringAfter("/", "") + } + + val paths = parseTsConfig(tsConfig) .asJsonObject?.get("compilerOptions") ?.asJsonObject?.get("paths") - ?.asJsonObject?.get(alias.substringBefore("/")) + + val aliasPath = (paths?.asJsonObject?.get(aliasPrefix) + ?: paths?.asJsonObject?.get("$aliasPrefix/*")) ?.asJsonArray?.get(0) ?.asJsonPrimitive?.content ?: throw Exception("Cannot find alias $alias in $tsConfig") - val normalized = aliasPath.replace(Regex("^\\.+/"), "") - val suffix = alias.substringAfter("/", "") + val normalized = aliasPath.replace(Regex("^\\.+/"), "").removeSuffix("/*") val resolved = if (suffix.isEmpty()) normalized else "$normalized/$suffix" return resolved.also { log.debug("Resolved alias $alias to $it") } }