@foundrykit/cli 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cli.js +10 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/add.ts +13 -1
- package/tests/dependency-resolution.test.ts +30 -0
package/dist/index.js
CHANGED
|
@@ -1618,6 +1618,9 @@ function getConfiguredImportPaths(config) {
|
|
|
1618
1618
|
};
|
|
1619
1619
|
}
|
|
1620
1620
|
function resolveImportBasePath(filePath, config, options = {}) {
|
|
1621
|
+
if (isPackageImportSpecifier(filePath)) {
|
|
1622
|
+
return filePath.replace(/\/$/, "");
|
|
1623
|
+
}
|
|
1621
1624
|
const normalizedPath = normalizeConfigPath(filePath).replace(
|
|
1622
1625
|
/\.(ts|js)x?$/,
|
|
1623
1626
|
""
|
|
@@ -1647,6 +1650,9 @@ function resolveImportBasePath(filePath, config, options = {}) {
|
|
|
1647
1650
|
function normalizeConfigPath(filePath) {
|
|
1648
1651
|
return filePath.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\.\/?$/, "").replace(/\/$/, "");
|
|
1649
1652
|
}
|
|
1653
|
+
function isPackageImportSpecifier(importPath) {
|
|
1654
|
+
return importPath.startsWith("@") && !importPath.startsWith("@/");
|
|
1655
|
+
}
|
|
1650
1656
|
function joinImportPath(basePath, childPath) {
|
|
1651
1657
|
const normalizedBase = basePath.replace(/\/$/, "");
|
|
1652
1658
|
const normalizedChild = childPath.replace(/^\//, "").replace(/\/$/, "");
|
|
@@ -1661,7 +1667,10 @@ function transformRegistryBarrelImports(content, sources, destinationBasePath, c
|
|
|
1661
1667
|
`import\\s+{([^}]+)}\\s+from\\s+["'](${sourcePattern})["'];?`,
|
|
1662
1668
|
"g"
|
|
1663
1669
|
);
|
|
1664
|
-
return content.replace(importPattern, (match, imports) => {
|
|
1670
|
+
return content.replace(importPattern, (match, imports, source) => {
|
|
1671
|
+
if (isPackageImportSpecifier(destinationBasePath)) {
|
|
1672
|
+
return match.replace(source, destinationBasePath);
|
|
1673
|
+
}
|
|
1665
1674
|
const groupedImports = groupImportsByComponent(imports, config, category);
|
|
1666
1675
|
return Array.from(groupedImports.entries()).map(([componentPath, specifiers]) => {
|
|
1667
1676
|
return `import { ${specifiers.join(", ")} } from "${destinationBasePath}/${componentPath}";`;
|