@foundrykit/cli 1.0.2 → 1.0.4
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 +14 -0
- package/dist/cli.js +200 -123
- package/dist/cli.js.map +1 -1
- package/dist/index.js +200 -123
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/add.ts +99 -64
- package/src/commands/init.ts +162 -47
package/dist/index.js
CHANGED
|
@@ -14,10 +14,10 @@ import path from "path";
|
|
|
14
14
|
import { execSync } from "child_process";
|
|
15
15
|
import inquirer from "inquirer";
|
|
16
16
|
function initCommand() {
|
|
17
|
-
return new Command("init").description("Initialize FoundryKit in your
|
|
17
|
+
return new Command("init").description("Initialize FoundryKit in your project").option("-f, --force", "overwrite existing files").option("--skip-install", "skip installing dependencies").action(async (options) => {
|
|
18
18
|
try {
|
|
19
19
|
console.log(chalk.blue("\u{1F680} Initializing FoundryKit..."));
|
|
20
|
-
await
|
|
20
|
+
await validateProject();
|
|
21
21
|
if (!options.force && await isFoundryKitInitialized()) {
|
|
22
22
|
const { shouldContinue } = await inquirer.prompt([
|
|
23
23
|
{
|
|
@@ -35,6 +35,8 @@ function initCommand() {
|
|
|
35
35
|
if (!options.skipInstall) {
|
|
36
36
|
await installDependencies();
|
|
37
37
|
}
|
|
38
|
+
await createConfigFile(options);
|
|
39
|
+
await installUtils();
|
|
38
40
|
await setupTailwindV4();
|
|
39
41
|
await createDirectories();
|
|
40
42
|
await createExampleFiles();
|
|
@@ -43,14 +45,18 @@ function initCommand() {
|
|
|
43
45
|
console.log(chalk.cyan("\n\u{1F4E6} Next steps:"));
|
|
44
46
|
console.log(
|
|
45
47
|
chalk.gray(
|
|
46
|
-
" 1. Add a component:
|
|
48
|
+
" 1. Add a component: pnpm dlx @foundrykit/cli add hero-minimal"
|
|
47
49
|
)
|
|
48
50
|
);
|
|
49
51
|
console.log(
|
|
50
|
-
chalk.gray(
|
|
52
|
+
chalk.gray(
|
|
53
|
+
" 2. List available components: pnpm dlx @foundrykit/cli list"
|
|
54
|
+
)
|
|
51
55
|
);
|
|
52
56
|
console.log(
|
|
53
|
-
chalk.gray(
|
|
57
|
+
chalk.gray(
|
|
58
|
+
" 3. Check out the docs: https://foundry-docs.umiflow.com"
|
|
59
|
+
)
|
|
54
60
|
);
|
|
55
61
|
} catch (error) {
|
|
56
62
|
console.error(chalk.red("\u274C Failed to initialize FoundryKit:"));
|
|
@@ -61,7 +67,7 @@ function initCommand() {
|
|
|
61
67
|
}
|
|
62
68
|
});
|
|
63
69
|
}
|
|
64
|
-
async function
|
|
70
|
+
async function validateProject() {
|
|
65
71
|
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
66
72
|
if (!fs.existsSync(packageJsonPath)) {
|
|
67
73
|
throw new Error(
|
|
@@ -81,82 +87,32 @@ async function validateNextJsProject() {
|
|
|
81
87
|
console.log(chalk.green("\u2705 Next.js project detected"));
|
|
82
88
|
}
|
|
83
89
|
async function isFoundryKitInitialized() {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
const packageJson2 = await fs.readJson(packageJsonPath);
|
|
87
|
-
const dependencies = {
|
|
88
|
-
...packageJson2.dependencies,
|
|
89
|
-
...packageJson2.devDependencies
|
|
90
|
-
};
|
|
91
|
-
return Object.keys(dependencies).some(
|
|
92
|
-
(dep) => dep.startsWith("@foundrykit/")
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
90
|
+
const configPath = path.join(process.cwd(), "foundrykit.config.json");
|
|
91
|
+
return fs.existsSync(configPath);
|
|
96
92
|
}
|
|
97
93
|
async function installDependencies() {
|
|
98
|
-
console.log(chalk.blue("\u{1F4E6} Installing
|
|
99
|
-
const
|
|
100
|
-
if (isWorkspace) {
|
|
101
|
-
console.log(
|
|
102
|
-
chalk.yellow("\u26A0\uFE0F Workspace detected - skipping dependency installation")
|
|
103
|
-
);
|
|
104
|
-
console.log(chalk.gray("Dependencies are already available via workspace"));
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const dependencies = [
|
|
108
|
-
"@foundrykit/primitives",
|
|
109
|
-
"@foundrykit/components",
|
|
110
|
-
"@foundrykit/blocks",
|
|
111
|
-
"@foundrykit/hooks",
|
|
112
|
-
"@foundrykit/animation",
|
|
113
|
-
"@foundrykit/tailwind"
|
|
114
|
-
];
|
|
94
|
+
console.log(chalk.blue("\u{1F4E6} Installing base dependencies..."));
|
|
95
|
+
const dependencies = ["clsx", "tailwind-merge"];
|
|
115
96
|
try {
|
|
116
97
|
const packageManager = detectPackageManager();
|
|
117
98
|
console.log(chalk.gray(`Using ${packageManager}...`));
|
|
118
|
-
const installCmd = packageManager === "npm" ? `npm install ${dependencies.join(" ")}` : packageManager === "yarn" ? `yarn add ${dependencies.join(" ")}` : `pnpm add ${dependencies.join(" ")}`;
|
|
99
|
+
const installCmd = packageManager === "npm" ? `npm install ${dependencies.join(" ")}` : packageManager === "yarn" ? `yarn add ${dependencies.join(" ")}` : packageManager === "bun" ? `bun add ${dependencies.join(" ")}` : `pnpm add ${dependencies.join(" ")}`;
|
|
119
100
|
execSync(installCmd, { stdio: "inherit" });
|
|
120
101
|
console.log(chalk.green("\u2705 Dependencies installed"));
|
|
121
102
|
} catch (error) {
|
|
122
|
-
|
|
123
|
-
"
|
|
103
|
+
console.log(
|
|
104
|
+
chalk.yellow("\u26A0\uFE0F Could not install dependencies automatically")
|
|
124
105
|
);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
const pnpmWorkspacePath = path.join(
|
|
130
|
-
process.cwd(),
|
|
131
|
-
"../../pnpm-workspace.yaml"
|
|
106
|
+
console.log(chalk.gray("Please install them manually:"));
|
|
107
|
+
console.log(
|
|
108
|
+
chalk.cyan(` ${detectPackageManager()} add ${dependencies.join(" ")}`)
|
|
132
109
|
);
|
|
133
|
-
if (fs.existsSync(pnpmWorkspacePath)) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
137
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
138
|
-
const packageJson2 = await fs.readJson(packageJsonPath);
|
|
139
|
-
const allDeps = {
|
|
140
|
-
...packageJson2.dependencies,
|
|
141
|
-
...packageJson2.devDependencies
|
|
142
|
-
};
|
|
143
|
-
const foundryKitPackages = Object.keys(allDeps).filter(
|
|
144
|
-
(key) => key.startsWith("@foundrykit/")
|
|
145
|
-
);
|
|
146
|
-
for (const pkg of foundryKitPackages) {
|
|
147
|
-
if (allDeps[pkg]?.includes("workspace:")) {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return false;
|
|
153
|
-
} catch {
|
|
154
|
-
return false;
|
|
155
110
|
}
|
|
156
111
|
}
|
|
157
112
|
function detectPackageManager() {
|
|
158
113
|
if (fs.existsSync("pnpm-lock.yaml")) return "pnpm";
|
|
159
114
|
if (fs.existsSync("yarn.lock")) return "yarn";
|
|
115
|
+
if (fs.existsSync("bun.lockb")) return "bun";
|
|
160
116
|
return "npm";
|
|
161
117
|
}
|
|
162
118
|
async function setupTailwindV4() {
|
|
@@ -389,7 +345,14 @@ async function updateLayoutImport(globalCssPath) {
|
|
|
389
345
|
}
|
|
390
346
|
async function createDirectories() {
|
|
391
347
|
console.log(chalk.blue("\u{1F4C1} Creating component directories..."));
|
|
392
|
-
const dirs = [
|
|
348
|
+
const dirs = [
|
|
349
|
+
"components/primitives",
|
|
350
|
+
"components/components",
|
|
351
|
+
"components/blocks",
|
|
352
|
+
"components/animations",
|
|
353
|
+
"lib",
|
|
354
|
+
"hooks"
|
|
355
|
+
];
|
|
393
356
|
for (const dir of dirs) {
|
|
394
357
|
await fs.ensureDir(path.join(process.cwd(), dir));
|
|
395
358
|
}
|
|
@@ -444,6 +407,102 @@ async function updatePackageScripts() {
|
|
|
444
407
|
await fs.writeJson(packageJsonPath, packageJson2, { spaces: 2 });
|
|
445
408
|
console.log(chalk.green("\u2705 Package scripts updated"));
|
|
446
409
|
}
|
|
410
|
+
async function createConfigFile(options) {
|
|
411
|
+
console.log(chalk.blue("\u{1F4DD} Creating configuration file..."));
|
|
412
|
+
const configPath = path.join(process.cwd(), "foundrykit.config.json");
|
|
413
|
+
if (fs.existsSync(configPath) && !options.force) {
|
|
414
|
+
console.log(chalk.yellow("\u26A0\uFE0F Configuration file already exists"));
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const framework = await detectFramework();
|
|
418
|
+
const isTypeScript = fs.existsSync(path.join(process.cwd(), "tsconfig.json"));
|
|
419
|
+
const config = {
|
|
420
|
+
version: "1.0.0",
|
|
421
|
+
registry: "https://foundry.umiflow.com",
|
|
422
|
+
paths: {
|
|
423
|
+
utils: "./src/lib/utils.ts",
|
|
424
|
+
primitives: "./src/components/primitives",
|
|
425
|
+
components: "./src/components/components",
|
|
426
|
+
blocks: "./src/components/blocks",
|
|
427
|
+
hooks: "./src/hooks",
|
|
428
|
+
animations: "./src/components/animations"
|
|
429
|
+
},
|
|
430
|
+
packageManager: detectPackageManager(),
|
|
431
|
+
typescript: isTypeScript,
|
|
432
|
+
framework,
|
|
433
|
+
tailwind: {
|
|
434
|
+
config: "./tailwind.config.js",
|
|
435
|
+
css: "./src/styles/globals.css"
|
|
436
|
+
},
|
|
437
|
+
aliases: {
|
|
438
|
+
"@": "./src",
|
|
439
|
+
"@/components": "./src/components",
|
|
440
|
+
"@/lib": "./src/lib",
|
|
441
|
+
"@/hooks": "./src/hooks"
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
if (framework === "next") {
|
|
445
|
+
const hasAppDir = fs.existsSync(path.join(process.cwd(), "app"));
|
|
446
|
+
if (hasAppDir && !fs.existsSync(path.join(process.cwd(), "src/app"))) {
|
|
447
|
+
config.paths = {
|
|
448
|
+
utils: "./lib/utils.ts",
|
|
449
|
+
primitives: "./components/primitives",
|
|
450
|
+
components: "./components/components",
|
|
451
|
+
blocks: "./components/blocks",
|
|
452
|
+
hooks: "./hooks",
|
|
453
|
+
animations: "./components/animations"
|
|
454
|
+
};
|
|
455
|
+
config.tailwind.css = "./app/globals.css";
|
|
456
|
+
config.aliases = {
|
|
457
|
+
"@": "./",
|
|
458
|
+
"@/components": "./components",
|
|
459
|
+
"@/lib": "./lib",
|
|
460
|
+
"@/hooks": "./hooks"
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
await fs.writeJson(configPath, config, { spaces: 2 });
|
|
465
|
+
console.log(chalk.green("\u2705 Created foundrykit.config.json"));
|
|
466
|
+
}
|
|
467
|
+
async function installUtils() {
|
|
468
|
+
console.log(chalk.blue("\u{1F4E6} Installing utils..."));
|
|
469
|
+
const configPath = path.join(process.cwd(), "foundrykit.config.json");
|
|
470
|
+
if (!fs.existsSync(configPath)) {
|
|
471
|
+
console.log(chalk.yellow("\u26A0\uFE0F Configuration file not found"));
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
const config = await fs.readJson(configPath);
|
|
475
|
+
const utilsPath = path.join(process.cwd(), config.paths.utils);
|
|
476
|
+
if (fs.existsSync(utilsPath)) {
|
|
477
|
+
console.log(chalk.yellow("\u26A0\uFE0F Utils file already exists"));
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
await fs.ensureDir(path.dirname(utilsPath));
|
|
481
|
+
const utilsContent = `import { type ClassValue, clsx } from 'clsx';
|
|
482
|
+
import { twMerge } from 'tailwind-merge';
|
|
483
|
+
|
|
484
|
+
export function cn(...inputs: ClassValue[]) {
|
|
485
|
+
return twMerge(clsx(inputs));
|
|
486
|
+
}
|
|
487
|
+
`;
|
|
488
|
+
await fs.writeFile(utilsPath, utilsContent);
|
|
489
|
+
console.log(chalk.green("\u2705 Created utils file"));
|
|
490
|
+
}
|
|
491
|
+
async function detectFramework() {
|
|
492
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
493
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
494
|
+
const packageJson2 = await fs.readJson(packageJsonPath);
|
|
495
|
+
const deps = {
|
|
496
|
+
...packageJson2.dependencies,
|
|
497
|
+
...packageJson2.devDependencies
|
|
498
|
+
};
|
|
499
|
+
if (deps.next) return "next";
|
|
500
|
+
if (deps.remix) return "remix";
|
|
501
|
+
if (deps.vite) return "vite";
|
|
502
|
+
if (deps.react) return "react";
|
|
503
|
+
}
|
|
504
|
+
return "react";
|
|
505
|
+
}
|
|
447
506
|
|
|
448
507
|
// src/commands/list.ts
|
|
449
508
|
import { Command as Command2 } from "commander";
|
|
@@ -861,7 +920,7 @@ function createGroupedChoices(components) {
|
|
|
861
920
|
async function addSingleComponent(id, options) {
|
|
862
921
|
console.log(chalk4.blue(`
|
|
863
922
|
\u{1F4E6} Adding ${id} to your project...`));
|
|
864
|
-
await
|
|
923
|
+
await validateProject2();
|
|
865
924
|
const registry = getRegistry();
|
|
866
925
|
try {
|
|
867
926
|
const componentData = await registry.getComponent(id);
|
|
@@ -909,29 +968,28 @@ async function addSingleComponent(id, options) {
|
|
|
909
968
|
throw error;
|
|
910
969
|
}
|
|
911
970
|
}
|
|
912
|
-
async function
|
|
971
|
+
async function validateProject2() {
|
|
913
972
|
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
914
973
|
if (!fs3.existsSync(packageJsonPath)) {
|
|
915
974
|
throw new Error(
|
|
916
975
|
"No package.json found. Please run this command in a project root."
|
|
917
976
|
);
|
|
918
977
|
}
|
|
919
|
-
const
|
|
920
|
-
|
|
921
|
-
...packageJson2.dependencies,
|
|
922
|
-
...packageJson2.devDependencies
|
|
923
|
-
};
|
|
924
|
-
const hasFoundryKit = Object.keys(dependencies).some(
|
|
925
|
-
(dep) => dep.startsWith("@foundrykit/")
|
|
926
|
-
);
|
|
927
|
-
if (!hasFoundryKit && !dependencies.next) {
|
|
978
|
+
const configPath = path3.join(process.cwd(), "foundrykit.config.json");
|
|
979
|
+
if (!fs3.existsSync(configPath)) {
|
|
928
980
|
throw new Error('FoundryKit not initialized. Run "foundrykit init" first.');
|
|
929
981
|
}
|
|
930
982
|
}
|
|
931
983
|
async function hasConflictingFiles(componentData, options) {
|
|
984
|
+
const config = await loadConfig();
|
|
932
985
|
const basePath = options.path || process.cwd();
|
|
933
986
|
for (const file of componentData.files) {
|
|
934
|
-
const
|
|
987
|
+
const resolvedPath = resolveComponentPath(
|
|
988
|
+
file.path,
|
|
989
|
+
componentData.category,
|
|
990
|
+
config
|
|
991
|
+
);
|
|
992
|
+
const filePath = path3.join(basePath, resolvedPath);
|
|
935
993
|
if (fs3.existsSync(filePath)) {
|
|
936
994
|
return true;
|
|
937
995
|
}
|
|
@@ -939,13 +997,19 @@ async function hasConflictingFiles(componentData, options) {
|
|
|
939
997
|
return false;
|
|
940
998
|
}
|
|
941
999
|
async function installComponentFiles(componentData, options) {
|
|
1000
|
+
const config = await loadConfig();
|
|
942
1001
|
const basePath = options.path || process.cwd();
|
|
943
1002
|
console.log(chalk4.blue("\u{1F4DD} Installing component files..."));
|
|
944
1003
|
for (const file of componentData.files) {
|
|
945
|
-
const
|
|
1004
|
+
const resolvedPath = resolveComponentPath(
|
|
1005
|
+
file.path,
|
|
1006
|
+
componentData.category,
|
|
1007
|
+
config
|
|
1008
|
+
);
|
|
1009
|
+
const filePath = path3.join(basePath, resolvedPath);
|
|
946
1010
|
await fs3.ensureDir(path3.dirname(filePath));
|
|
947
1011
|
await fs3.writeFile(filePath, file.content);
|
|
948
|
-
console.log(chalk4.green(` \u2713 ${
|
|
1012
|
+
console.log(chalk4.green(` \u2713 ${resolvedPath}`));
|
|
949
1013
|
}
|
|
950
1014
|
}
|
|
951
1015
|
async function handlePackageDependencies(componentData) {
|
|
@@ -953,13 +1017,6 @@ async function handlePackageDependencies(componentData) {
|
|
|
953
1017
|
if (componentData.packageDependencies?.length) {
|
|
954
1018
|
componentData.packageDependencies.forEach((dep) => allDependencies.add(dep));
|
|
955
1019
|
}
|
|
956
|
-
if (componentData.registryDependencies?.includes("utils")) {
|
|
957
|
-
allDependencies.add("clsx");
|
|
958
|
-
allDependencies.add("tailwind-merge");
|
|
959
|
-
}
|
|
960
|
-
if (componentData.id === "button") {
|
|
961
|
-
allDependencies.add("class-variance-authority");
|
|
962
|
-
}
|
|
963
1020
|
if (allDependencies.size === 0) {
|
|
964
1021
|
return;
|
|
965
1022
|
}
|
|
@@ -1015,47 +1072,67 @@ async function detectPackageManager2() {
|
|
|
1015
1072
|
}
|
|
1016
1073
|
return "pnpm";
|
|
1017
1074
|
}
|
|
1018
|
-
function showUsageExample(componentData) {
|
|
1075
|
+
async function showUsageExample(componentData) {
|
|
1076
|
+
const config = await loadConfig();
|
|
1019
1077
|
console.log(chalk4.cyan("\n\u{1F4A1} Usage:"));
|
|
1020
1078
|
const componentName = componentData.name.replace(/\s+/g, "");
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1079
|
+
const importPath = getImportPath(componentData, config);
|
|
1080
|
+
console.log(chalk4.gray(`import { ${componentName} } from "${importPath}"`));
|
|
1081
|
+
if (componentData.usageExample) {
|
|
1082
|
+
console.log(chalk4.gray(`
|
|
1083
|
+
${componentData.usageExample}`));
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
async function loadConfig() {
|
|
1087
|
+
const configPath = path3.join(process.cwd(), "foundrykit.config.json");
|
|
1088
|
+
if (!fs3.existsSync(configPath)) {
|
|
1089
|
+
throw new Error(
|
|
1090
|
+
'Configuration file not found. Run "foundrykit init" first.'
|
|
1026
1091
|
);
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1092
|
+
}
|
|
1093
|
+
return fs3.readJson(configPath);
|
|
1094
|
+
}
|
|
1095
|
+
function resolveComponentPath(originalPath, category, config) {
|
|
1096
|
+
const categoryPath = config.paths[category] || config.paths.components;
|
|
1097
|
+
const fileName = path3.basename(originalPath);
|
|
1098
|
+
const componentName = path3.dirname(originalPath).split("/").pop() || "";
|
|
1099
|
+
if (category === "primitives") {
|
|
1100
|
+
return path3.join(categoryPath, componentName, fileName);
|
|
1101
|
+
} else if (category === "components") {
|
|
1102
|
+
return path3.join(
|
|
1103
|
+
config.paths.components,
|
|
1104
|
+
"components",
|
|
1105
|
+
componentName,
|
|
1106
|
+
fileName
|
|
1032
1107
|
);
|
|
1033
|
-
} else if (
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1108
|
+
} else if (category === "blocks") {
|
|
1109
|
+
return path3.join(
|
|
1110
|
+
config.paths.blocks || path3.join(config.paths.components, "blocks"),
|
|
1111
|
+
componentName,
|
|
1112
|
+
fileName
|
|
1038
1113
|
);
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
console.log(chalk4.gray('\n<Input placeholder="Enter text..." />'));
|
|
1045
|
-
} else if (componentData.id.includes("hero")) {
|
|
1046
|
-
console.log(chalk4.gray(`
|
|
1047
|
-
<${componentName} />`));
|
|
1048
|
-
} else if (componentData.id === "card") {
|
|
1049
|
-
console.log(chalk4.gray("\n<Card>"));
|
|
1050
|
-
console.log(chalk4.gray(" <CardHeader>"));
|
|
1051
|
-
console.log(chalk4.gray(" <CardTitle>Title</CardTitle>"));
|
|
1052
|
-
console.log(
|
|
1053
|
-
chalk4.gray(" <CardDescription>Description</CardDescription>")
|
|
1114
|
+
} else if (category === "animations") {
|
|
1115
|
+
return path3.join(
|
|
1116
|
+
config.paths.animations || path3.join(config.paths.components, "animations"),
|
|
1117
|
+
componentName,
|
|
1118
|
+
fileName
|
|
1054
1119
|
);
|
|
1055
|
-
console.log(chalk4.gray(" </CardHeader>"));
|
|
1056
|
-
console.log(chalk4.gray(" <CardContent>Content</CardContent>"));
|
|
1057
|
-
console.log(chalk4.gray("</Card>"));
|
|
1058
1120
|
}
|
|
1121
|
+
return originalPath;
|
|
1122
|
+
}
|
|
1123
|
+
function getImportPath(componentData, config) {
|
|
1124
|
+
const aliases = config.aliases || {};
|
|
1125
|
+
const componentName = path3.basename(componentData.files[0].path, ".tsx");
|
|
1126
|
+
if (componentData.category === "primitives") {
|
|
1127
|
+
return `@/components/ui/${componentName}`;
|
|
1128
|
+
} else if (componentData.category === "components") {
|
|
1129
|
+
return `@/components/components/${componentName}`;
|
|
1130
|
+
} else if (componentData.category === "blocks") {
|
|
1131
|
+
return `@/components/blocks/${componentName}`;
|
|
1132
|
+
} else if (componentData.category === "animations") {
|
|
1133
|
+
return `@/components/animations/${componentName}`;
|
|
1134
|
+
}
|
|
1135
|
+
return `@/components/${componentName}`;
|
|
1059
1136
|
}
|
|
1060
1137
|
|
|
1061
1138
|
// src/commands/update.ts
|