@foundrykit/cli 2.0.6 → 2.0.7
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 +8 -0
- package/dist/cli.js +240 -62
- package/dist/cli.js.map +1 -1
- package/dist/index.js +240 -62
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/add.ts +153 -16
- package/src/commands/init.ts +13 -0
- package/src/commands/list.ts +10 -13
- package/src/lib/constants.ts +26 -0
- package/src/lib/registry.ts +99 -39
- package/tests/dependency-resolution.test.ts +33 -11
package/CHANGELOG.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -20,6 +20,30 @@ var CLI_VERSION = "1.0.16";
|
|
|
20
20
|
var DEFAULT_REGISTRY_URL = "https://foundry.umiflow.com";
|
|
21
21
|
var CACHE_TTL = 24 * 60 * 60 * 1e3;
|
|
22
22
|
var CACHE_DIR = ".foundrykit";
|
|
23
|
+
var REGISTRY_CATEGORY_ORDER = [
|
|
24
|
+
"primitives",
|
|
25
|
+
"components",
|
|
26
|
+
"blocks",
|
|
27
|
+
"animations",
|
|
28
|
+
"maps",
|
|
29
|
+
"hooks",
|
|
30
|
+
"packages"
|
|
31
|
+
];
|
|
32
|
+
var FOUNDRYKIT_PACKAGE_ALIASES = [
|
|
33
|
+
"animation",
|
|
34
|
+
"blocks",
|
|
35
|
+
"cli",
|
|
36
|
+
"components",
|
|
37
|
+
"eslint-config",
|
|
38
|
+
"hooks",
|
|
39
|
+
"maps",
|
|
40
|
+
"prettier-config",
|
|
41
|
+
"primitives",
|
|
42
|
+
"tailwind",
|
|
43
|
+
"typescript-config",
|
|
44
|
+
"types",
|
|
45
|
+
"utils"
|
|
46
|
+
];
|
|
23
47
|
|
|
24
48
|
// src/commands/init.ts
|
|
25
49
|
function initCommand() {
|
|
@@ -204,6 +228,10 @@ async function getPathConfiguration(structure, skipPrompts) {
|
|
|
204
228
|
structure.componentsPath || path.join(structure.baseDir, "components"),
|
|
205
229
|
"blocks"
|
|
206
230
|
),
|
|
231
|
+
maps: path.join(
|
|
232
|
+
structure.componentsPath || path.join(structure.baseDir, "components"),
|
|
233
|
+
"maps"
|
|
234
|
+
),
|
|
207
235
|
animations: path.join(
|
|
208
236
|
structure.componentsPath || path.join(structure.baseDir, "components"),
|
|
209
237
|
"animations"
|
|
@@ -271,6 +299,12 @@ async function getPathConfiguration(structure, skipPrompts) {
|
|
|
271
299
|
message: "Hooks directory:",
|
|
272
300
|
default: defaults.hooks
|
|
273
301
|
},
|
|
302
|
+
{
|
|
303
|
+
type: "input",
|
|
304
|
+
name: "maps",
|
|
305
|
+
message: "Maps directory:",
|
|
306
|
+
default: defaults.maps
|
|
307
|
+
},
|
|
274
308
|
{
|
|
275
309
|
type: "input",
|
|
276
310
|
name: "animations",
|
|
@@ -564,6 +598,7 @@ async function createDirectories(pathConfig) {
|
|
|
564
598
|
pathConfig.primitives,
|
|
565
599
|
pathConfig.components,
|
|
566
600
|
pathConfig.blocks,
|
|
601
|
+
pathConfig.maps,
|
|
567
602
|
pathConfig.animations,
|
|
568
603
|
pathConfig.hooks,
|
|
569
604
|
pathConfig.lib
|
|
@@ -660,6 +695,7 @@ async function createConfigFile(options, structure, pathConfig) {
|
|
|
660
695
|
components: normalizePath(pathConfig.components),
|
|
661
696
|
blocks: normalizePath(pathConfig.blocks),
|
|
662
697
|
hooks: normalizePath(pathConfig.hooks),
|
|
698
|
+
maps: normalizePath(pathConfig.maps),
|
|
663
699
|
animations: normalizePath(pathConfig.animations)
|
|
664
700
|
},
|
|
665
701
|
packageManager: structure.packageManager,
|
|
@@ -739,12 +775,20 @@ var RegistryService = class {
|
|
|
739
775
|
}
|
|
740
776
|
const components = await response.json();
|
|
741
777
|
await this.updateCache(components);
|
|
742
|
-
return
|
|
778
|
+
return this.filterComponents(
|
|
779
|
+
this.withFoundryKitPackages(components),
|
|
780
|
+
category,
|
|
781
|
+
search
|
|
782
|
+
);
|
|
743
783
|
} catch (error) {
|
|
744
784
|
const cache = await this.loadCache();
|
|
745
785
|
if (cache && this.isCacheValid(cache)) {
|
|
746
786
|
console.log(chalk2.yellow("Using cached registry data"));
|
|
747
|
-
return this.filterComponents(
|
|
787
|
+
return this.filterComponents(
|
|
788
|
+
this.withFoundryKitPackages(cache.components),
|
|
789
|
+
category,
|
|
790
|
+
search
|
|
791
|
+
);
|
|
748
792
|
}
|
|
749
793
|
throw new Error(
|
|
750
794
|
`Failed to connect to registry: ${error instanceof Error ? error.message : "Unknown error"}
|
|
@@ -760,6 +804,10 @@ Try again later or check your internet connection.`
|
|
|
760
804
|
if (this.isSpecialDependency(id)) {
|
|
761
805
|
return this.createSpecialDependency(id);
|
|
762
806
|
}
|
|
807
|
+
const foundryKitPackage = this.resolveFoundryKitPackageName(id);
|
|
808
|
+
const isExplicitFoundryKitPackage = id.startsWith("@foundrykit/") || id.endsWith("-plugin") || FOUNDRYKIT_PACKAGE_ALIASES.includes(
|
|
809
|
+
id
|
|
810
|
+
);
|
|
763
811
|
const cache = await this.loadCache();
|
|
764
812
|
const cachedComponent = cache?.componentData?.[id];
|
|
765
813
|
const hasValidCache = cache ? this.isCacheValid(cache) : false;
|
|
@@ -773,6 +821,9 @@ Try again later or check your internet connection.`
|
|
|
773
821
|
const response = await fetch(url);
|
|
774
822
|
if (!response.ok) {
|
|
775
823
|
if (response.status === 404) {
|
|
824
|
+
if (foundryKitPackage && isExplicitFoundryKitPackage) {
|
|
825
|
+
return this.createFoundryKitPackageDependency(foundryKitPackage);
|
|
826
|
+
}
|
|
776
827
|
throw new Error(`Component "${id}" not found in registry`);
|
|
777
828
|
}
|
|
778
829
|
throw new Error(
|
|
@@ -783,6 +834,9 @@ Try again later or check your internet connection.`
|
|
|
783
834
|
await this.cacheComponent(component);
|
|
784
835
|
return component;
|
|
785
836
|
} catch (error) {
|
|
837
|
+
if (foundryKitPackage && isExplicitFoundryKitPackage) {
|
|
838
|
+
return this.createFoundryKitPackageDependency(foundryKitPackage);
|
|
839
|
+
}
|
|
786
840
|
if (cachedComponent) {
|
|
787
841
|
console.log(chalk2.yellow(`Using cached data for component: ${id}`));
|
|
788
842
|
return cachedComponent;
|
|
@@ -805,8 +859,9 @@ Try again later or check your internet connection.`
|
|
|
805
859
|
"cn",
|
|
806
860
|
// Utils aliases
|
|
807
861
|
"hooks",
|
|
808
|
-
"types"
|
|
862
|
+
"types",
|
|
809
863
|
// Package dependencies
|
|
864
|
+
"maps"
|
|
810
865
|
];
|
|
811
866
|
return specialDependencies.includes(id);
|
|
812
867
|
}
|
|
@@ -837,42 +892,13 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
837
892
|
};
|
|
838
893
|
}
|
|
839
894
|
if (id === "hooks") {
|
|
840
|
-
|
|
841
|
-
if (isInstalled) {
|
|
842
|
-
return {
|
|
843
|
-
id: "hooks",
|
|
844
|
-
name: "Hooks",
|
|
845
|
-
description: "Custom React hooks package",
|
|
846
|
-
category: "primitives",
|
|
847
|
-
files: [],
|
|
848
|
-
// No files to install, it's a package
|
|
849
|
-
registryDependencies: [],
|
|
850
|
-
packageDependencies: ["@foundrykit/hooks"]
|
|
851
|
-
};
|
|
852
|
-
} else {
|
|
853
|
-
throw new Error(
|
|
854
|
-
'Package "@foundrykit/hooks" is not installed. Please install it first: pnpm add @foundrykit/hooks'
|
|
855
|
-
);
|
|
856
|
-
}
|
|
895
|
+
return this.createFoundryKitPackageDependency("@foundrykit/hooks");
|
|
857
896
|
}
|
|
858
897
|
if (id === "types") {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
name: "Types",
|
|
864
|
-
description: "TypeScript type definitions",
|
|
865
|
-
category: "primitives",
|
|
866
|
-
files: [],
|
|
867
|
-
// No files to install, it's a package
|
|
868
|
-
registryDependencies: [],
|
|
869
|
-
packageDependencies: ["@foundrykit/types"]
|
|
870
|
-
};
|
|
871
|
-
} else {
|
|
872
|
-
throw new Error(
|
|
873
|
-
'Package "@foundrykit/types" is not installed. Please install it first: pnpm add @foundrykit/types'
|
|
874
|
-
);
|
|
875
|
-
}
|
|
898
|
+
return this.createFoundryKitPackageDependency("@foundrykit/types");
|
|
899
|
+
}
|
|
900
|
+
if (id === "maps") {
|
|
901
|
+
return this.createFoundryKitPackageDependency("@foundrykit/maps");
|
|
876
902
|
}
|
|
877
903
|
throw new Error(`Unknown special dependency: ${id}`);
|
|
878
904
|
}
|
|
@@ -896,6 +922,47 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
896
922
|
return false;
|
|
897
923
|
}
|
|
898
924
|
}
|
|
925
|
+
resolveFoundryKitPackageName(id) {
|
|
926
|
+
if (/^@foundrykit\/[a-z0-9][a-z0-9-]*$/i.test(id)) {
|
|
927
|
+
return id;
|
|
928
|
+
}
|
|
929
|
+
if (FOUNDRYKIT_PACKAGE_ALIASES.includes(
|
|
930
|
+
id
|
|
931
|
+
) || /^[a-z0-9][a-z0-9-]*-plugin$/i.test(id)) {
|
|
932
|
+
return `@foundrykit/${id}`;
|
|
933
|
+
}
|
|
934
|
+
return null;
|
|
935
|
+
}
|
|
936
|
+
createFoundryKitPackageDependency(packageName) {
|
|
937
|
+
const id = packageName.replace("@foundrykit/", "");
|
|
938
|
+
const category = id === "maps" ? "maps" : id === "hooks" ? "hooks" : "packages";
|
|
939
|
+
return {
|
|
940
|
+
id,
|
|
941
|
+
name: this.toDisplayName(id),
|
|
942
|
+
description: `${packageName} npm package`,
|
|
943
|
+
category,
|
|
944
|
+
files: [],
|
|
945
|
+
registryDependencies: [],
|
|
946
|
+
packageDependencies: [packageName]
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
withFoundryKitPackages(components) {
|
|
950
|
+
const packageEntries = FOUNDRYKIT_PACKAGE_ALIASES.map((packageId) => ({
|
|
951
|
+
id: packageId,
|
|
952
|
+
name: this.toDisplayName(packageId),
|
|
953
|
+
category: packageId === "maps" ? "maps" : packageId === "hooks" ? "hooks" : "packages",
|
|
954
|
+
description: `@foundrykit/${packageId} npm package`,
|
|
955
|
+
packageDependencies: [`@foundrykit/${packageId}`]
|
|
956
|
+
}));
|
|
957
|
+
const seenIds = new Set(components.map((component) => component.id));
|
|
958
|
+
return [
|
|
959
|
+
...components,
|
|
960
|
+
...packageEntries.filter((component) => !seenIds.has(component.id))
|
|
961
|
+
];
|
|
962
|
+
}
|
|
963
|
+
toDisplayName(id) {
|
|
964
|
+
return id.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
965
|
+
}
|
|
899
966
|
/**
|
|
900
967
|
* Update the local cache with new component list
|
|
901
968
|
*/
|
|
@@ -1028,12 +1095,7 @@ function listCommand() {
|
|
|
1028
1095
|
console.log(chalk3.blue("\u{1F4E6} Available FoundryKit components:"));
|
|
1029
1096
|
const registry = getRegistry();
|
|
1030
1097
|
if (options.category) {
|
|
1031
|
-
const validCategories =
|
|
1032
|
-
"primitives",
|
|
1033
|
-
"components",
|
|
1034
|
-
"blocks",
|
|
1035
|
-
"animations"
|
|
1036
|
-
];
|
|
1098
|
+
const validCategories = REGISTRY_CATEGORY_ORDER;
|
|
1037
1099
|
if (!validCategories.includes(options.category)) {
|
|
1038
1100
|
console.error(chalk3.red(`Invalid category: ${options.category}`));
|
|
1039
1101
|
console.log(
|
|
@@ -1088,11 +1150,14 @@ function displayComponents(components) {
|
|
|
1088
1150
|
},
|
|
1089
1151
|
{}
|
|
1090
1152
|
);
|
|
1153
|
+
const knownCategories = new Set(
|
|
1154
|
+
REGISTRY_CATEGORY_ORDER
|
|
1155
|
+
);
|
|
1091
1156
|
const categoryOrder = [
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1157
|
+
...REGISTRY_CATEGORY_ORDER,
|
|
1158
|
+
...Object.keys(grouped).filter(
|
|
1159
|
+
(category) => !knownCategories.has(category)
|
|
1160
|
+
)
|
|
1096
1161
|
];
|
|
1097
1162
|
for (const category of categoryOrder) {
|
|
1098
1163
|
const items = grouped[category];
|
|
@@ -1203,11 +1268,12 @@ async function selectComponentsInteractively() {
|
|
|
1203
1268
|
}
|
|
1204
1269
|
}
|
|
1205
1270
|
function createGroupedChoices(components) {
|
|
1271
|
+
const knownCategories = new Set(
|
|
1272
|
+
REGISTRY_CATEGORY_ORDER
|
|
1273
|
+
);
|
|
1206
1274
|
const categories = [
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
"blocks",
|
|
1210
|
-
"animations"
|
|
1275
|
+
...REGISTRY_CATEGORY_ORDER,
|
|
1276
|
+
...components.map((component) => component.category).filter((category) => !knownCategories.has(category))
|
|
1211
1277
|
];
|
|
1212
1278
|
const choices = [];
|
|
1213
1279
|
for (const category of categories) {
|
|
@@ -1331,6 +1397,9 @@ async function hasConflictingFiles(componentData, options) {
|
|
|
1331
1397
|
async function installComponentFiles(componentData, options) {
|
|
1332
1398
|
const config = await loadConfig();
|
|
1333
1399
|
const basePath = options.path || process.cwd();
|
|
1400
|
+
if (componentData.files.length === 0) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1334
1403
|
console.log(chalk4.blue("\u{1F4DD} Installing component files..."));
|
|
1335
1404
|
for (const file of componentData.files) {
|
|
1336
1405
|
let resolvedPath;
|
|
@@ -1432,6 +1501,15 @@ async function detectPackageManager2() {
|
|
|
1432
1501
|
async function showUsageExample(componentData) {
|
|
1433
1502
|
const config = await loadConfig();
|
|
1434
1503
|
console.log(chalk4.cyan("\n\u{1F4A1} Usage:"));
|
|
1504
|
+
if (componentData.files.length === 0) {
|
|
1505
|
+
const packageName = componentData.packageDependencies?.find(
|
|
1506
|
+
(dep) => dep.startsWith("@foundrykit/")
|
|
1507
|
+
);
|
|
1508
|
+
if (packageName) {
|
|
1509
|
+
console.log(chalk4.gray(`import { ... } from "${packageName}"`));
|
|
1510
|
+
}
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1435
1513
|
const componentName = componentData.name.replace(/\s+/g, "");
|
|
1436
1514
|
const importPath = getImportPath(componentData, config);
|
|
1437
1515
|
console.log(chalk4.gray(`import { ${componentName} } from "${importPath}"`));
|
|
@@ -1480,6 +1558,20 @@ function transformImportsForConfig(content, config) {
|
|
|
1480
1558
|
config,
|
|
1481
1559
|
"animations"
|
|
1482
1560
|
);
|
|
1561
|
+
transformed = transformRegistryBarrelImports(
|
|
1562
|
+
transformed,
|
|
1563
|
+
["@foundrykit/maps", "@/components/maps"],
|
|
1564
|
+
importPaths.maps,
|
|
1565
|
+
config,
|
|
1566
|
+
"maps"
|
|
1567
|
+
);
|
|
1568
|
+
transformed = transformRegistryBarrelImports(
|
|
1569
|
+
transformed,
|
|
1570
|
+
["@foundrykit/hooks", "@/hooks"],
|
|
1571
|
+
importPaths.hooks,
|
|
1572
|
+
config,
|
|
1573
|
+
"hooks"
|
|
1574
|
+
);
|
|
1483
1575
|
transformed = transformed.replace(/@foundrykit\/utils/g, importPaths.utils).replace(/@\/lib\/utils/g, importPaths.utils);
|
|
1484
1576
|
return transformed;
|
|
1485
1577
|
}
|
|
@@ -1489,25 +1581,56 @@ function getConfiguredImportPaths(config) {
|
|
|
1489
1581
|
components: "components",
|
|
1490
1582
|
blocks: "components/blocks",
|
|
1491
1583
|
animations: "components/animations",
|
|
1584
|
+
hooks: "hooks",
|
|
1585
|
+
maps: "components/maps",
|
|
1492
1586
|
utils: "lib/utils"
|
|
1493
1587
|
};
|
|
1494
1588
|
return {
|
|
1495
|
-
primitives: resolveImportBasePath(paths.primitives, config
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1589
|
+
primitives: resolveImportBasePath(paths.primitives, config, {
|
|
1590
|
+
preferRootAlias: true
|
|
1591
|
+
}),
|
|
1592
|
+
components: resolveImportBasePath(paths.components, config, {
|
|
1593
|
+
preferRootAlias: true
|
|
1594
|
+
}),
|
|
1595
|
+
blocks: resolveImportBasePath(paths.blocks, config, {
|
|
1596
|
+
preferRootAlias: true
|
|
1597
|
+
}),
|
|
1598
|
+
animations: resolveImportBasePath(paths.animations, config, {
|
|
1599
|
+
preferRootAlias: true
|
|
1600
|
+
}),
|
|
1601
|
+
maps: resolveImportBasePath(
|
|
1602
|
+
paths.maps ?? joinImportPath(paths.components, "maps"),
|
|
1603
|
+
config,
|
|
1604
|
+
{
|
|
1605
|
+
preferRootAlias: true
|
|
1606
|
+
}
|
|
1607
|
+
),
|
|
1608
|
+
hooks: resolveImportBasePath(paths.hooks ?? "hooks", config, {
|
|
1609
|
+
preferRootAlias: true
|
|
1610
|
+
}),
|
|
1611
|
+
packages: resolveImportBasePath(paths.components, config, {
|
|
1612
|
+
preferRootAlias: true
|
|
1613
|
+
}),
|
|
1499
1614
|
utils: resolveImportBasePath(paths.utils, config).replace(
|
|
1500
1615
|
/\.(ts|js)x?$/,
|
|
1501
1616
|
""
|
|
1502
1617
|
)
|
|
1503
1618
|
};
|
|
1504
1619
|
}
|
|
1505
|
-
function resolveImportBasePath(filePath, config) {
|
|
1620
|
+
function resolveImportBasePath(filePath, config, options = {}) {
|
|
1506
1621
|
const normalizedPath = normalizeConfigPath(filePath).replace(
|
|
1507
1622
|
/\.(ts|js)x?$/,
|
|
1508
1623
|
""
|
|
1509
1624
|
);
|
|
1510
1625
|
const aliases = config?.aliases ?? {};
|
|
1626
|
+
if (options.preferRootAlias && aliases["@"]) {
|
|
1627
|
+
const rootTarget = normalizeConfigPath(aliases["@"]);
|
|
1628
|
+
const matchesRoot = normalizedPath === rootTarget || rootTarget !== "" && normalizedPath.startsWith(`${rootTarget}/`) || rootTarget === "";
|
|
1629
|
+
if (matchesRoot) {
|
|
1630
|
+
const relativePath = rootTarget === "" ? normalizedPath : normalizedPath.slice(rootTarget.length).replace(/^\//, "");
|
|
1631
|
+
return joinImportPath("@", relativePath);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1511
1634
|
const aliasMatches = Object.entries(aliases).map(([alias, target]) => ({
|
|
1512
1635
|
alias,
|
|
1513
1636
|
target: normalizeConfigPath(target)
|
|
@@ -1583,7 +1706,7 @@ function getExportNameFromSpecifier(specifier) {
|
|
|
1583
1706
|
}
|
|
1584
1707
|
function getInstalledComponentExportMap(config, category) {
|
|
1585
1708
|
const exportMap = /* @__PURE__ */ new Map();
|
|
1586
|
-
const categoryPath = config
|
|
1709
|
+
const categoryPath = getConfiguredCategoryPath(config, category);
|
|
1587
1710
|
if (!categoryPath) {
|
|
1588
1711
|
return exportMap;
|
|
1589
1712
|
}
|
|
@@ -1639,12 +1762,14 @@ function resolveComponentPath(originalPath, category, config) {
|
|
|
1639
1762
|
components: "components",
|
|
1640
1763
|
blocks: "components/blocks",
|
|
1641
1764
|
animations: "components/animations",
|
|
1765
|
+
hooks: "hooks",
|
|
1766
|
+
maps: "components/maps",
|
|
1642
1767
|
utils: "lib/utils"
|
|
1643
1768
|
};
|
|
1644
1769
|
if (originalPath === "lib/utils.ts") {
|
|
1645
1770
|
return paths.utils || "lib/utils.ts";
|
|
1646
1771
|
}
|
|
1647
|
-
const categoryPath =
|
|
1772
|
+
const categoryPath = getConfiguredCategoryPath(config, category) || paths.components;
|
|
1648
1773
|
const fileName = path3.basename(originalPath);
|
|
1649
1774
|
const componentName = path3.dirname(originalPath).split("/").pop() || "";
|
|
1650
1775
|
if (category === "primitives") {
|
|
@@ -1663,28 +1788,81 @@ function resolveComponentPath(originalPath, category, config) {
|
|
|
1663
1788
|
componentName,
|
|
1664
1789
|
fileName
|
|
1665
1790
|
);
|
|
1791
|
+
} else if (category === "maps") {
|
|
1792
|
+
return path3.join(
|
|
1793
|
+
paths.maps || path3.join(paths.components, "maps"),
|
|
1794
|
+
componentName,
|
|
1795
|
+
fileName
|
|
1796
|
+
);
|
|
1797
|
+
} else if (category === "hooks") {
|
|
1798
|
+
return path3.join(paths.hooks || "hooks", componentName, fileName);
|
|
1799
|
+
} else if (category === "packages") {
|
|
1800
|
+
return path3.join(paths.components, componentName, fileName);
|
|
1666
1801
|
}
|
|
1667
1802
|
return originalPath;
|
|
1668
1803
|
}
|
|
1804
|
+
function getConfiguredCategoryPath(config, category) {
|
|
1805
|
+
const paths = config.paths;
|
|
1806
|
+
switch (category) {
|
|
1807
|
+
case "primitives":
|
|
1808
|
+
return paths.primitives;
|
|
1809
|
+
case "components":
|
|
1810
|
+
return paths.components;
|
|
1811
|
+
case "blocks":
|
|
1812
|
+
return paths.blocks;
|
|
1813
|
+
case "animations":
|
|
1814
|
+
return paths.animations;
|
|
1815
|
+
case "maps":
|
|
1816
|
+
return paths.maps ?? path3.join(paths.components, "maps");
|
|
1817
|
+
case "hooks":
|
|
1818
|
+
return paths.hooks ?? "hooks";
|
|
1819
|
+
case "packages":
|
|
1820
|
+
return paths.components;
|
|
1821
|
+
default:
|
|
1822
|
+
return void 0;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1669
1825
|
function getImportPath(componentData, config) {
|
|
1670
1826
|
const paths = config?.paths || {
|
|
1671
1827
|
primitives: "components/primitives",
|
|
1672
1828
|
components: "components",
|
|
1673
1829
|
blocks: "components/blocks",
|
|
1674
1830
|
animations: "components/animations",
|
|
1831
|
+
hooks: "hooks",
|
|
1832
|
+
maps: "components/maps",
|
|
1675
1833
|
utils: "lib/utils"
|
|
1676
1834
|
};
|
|
1677
1835
|
const componentName = path3.basename(
|
|
1678
1836
|
path3.dirname(componentData.files[0]?.path || "")
|
|
1679
1837
|
);
|
|
1680
1838
|
if (componentData.category === "primitives") {
|
|
1681
|
-
return `${resolveImportBasePath(paths.primitives, config
|
|
1839
|
+
return `${resolveImportBasePath(paths.primitives, config, {
|
|
1840
|
+
preferRootAlias: true
|
|
1841
|
+
})}/${componentName}`;
|
|
1682
1842
|
} else if (componentData.category === "components") {
|
|
1683
|
-
return `${resolveImportBasePath(paths.components, config
|
|
1843
|
+
return `${resolveImportBasePath(paths.components, config, {
|
|
1844
|
+
preferRootAlias: true
|
|
1845
|
+
})}/${componentName}`;
|
|
1684
1846
|
} else if (componentData.category === "blocks") {
|
|
1685
|
-
return `${resolveImportBasePath(paths.blocks, config
|
|
1847
|
+
return `${resolveImportBasePath(paths.blocks, config, {
|
|
1848
|
+
preferRootAlias: true
|
|
1849
|
+
})}/${componentName}`;
|
|
1686
1850
|
} else if (componentData.category === "animations") {
|
|
1687
|
-
return `${resolveImportBasePath(paths.animations, config
|
|
1851
|
+
return `${resolveImportBasePath(paths.animations, config, {
|
|
1852
|
+
preferRootAlias: true
|
|
1853
|
+
})}/${componentName}`;
|
|
1854
|
+
} else if (componentData.category === "maps") {
|
|
1855
|
+
return `${resolveImportBasePath(
|
|
1856
|
+
paths.maps || path3.join(paths.components, "maps"),
|
|
1857
|
+
config,
|
|
1858
|
+
{
|
|
1859
|
+
preferRootAlias: true
|
|
1860
|
+
}
|
|
1861
|
+
)}/${componentName}`;
|
|
1862
|
+
} else if (componentData.category === "hooks") {
|
|
1863
|
+
return `${resolveImportBasePath(paths.hooks || "hooks", config, {
|
|
1864
|
+
preferRootAlias: true
|
|
1865
|
+
})}/${componentName}`;
|
|
1688
1866
|
}
|
|
1689
1867
|
return `@/components/${componentName}`;
|
|
1690
1868
|
}
|