bunkit-cli 1.1.0 → 1.1.2
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/dist/index.js +115 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26323,7 +26323,9 @@ var themes = {
|
|
|
26323
26323
|
function generateThemeCSS(theme, customRadius) {
|
|
26324
26324
|
const radius = customRadius || theme.light.radius;
|
|
26325
26325
|
return `@import "tailwindcss";
|
|
26326
|
-
@
|
|
26326
|
+
@source "../../../apps/**/*.{ts,tsx}";
|
|
26327
|
+
@source "../../../components/**/*.{ts,tsx}";
|
|
26328
|
+
@source "../**/*.{ts,tsx}";
|
|
26327
26329
|
|
|
26328
26330
|
:root {
|
|
26329
26331
|
--radius: ${radius};
|
|
@@ -26457,13 +26459,27 @@ async function installShadcnComponents(projectPath, components, options = {}) {
|
|
|
26457
26459
|
const cwd2 = options.cwd || projectPath;
|
|
26458
26460
|
const stdio = options.silent ? "pipe" : "inherit";
|
|
26459
26461
|
const targetCwd = options.isMonorepo ? join(projectPath, "packages/ui") : cwd2;
|
|
26462
|
+
try {
|
|
26463
|
+
logger.debug("Installing dependencies with Bun before running shadcn CLI...");
|
|
26464
|
+
await execa("bun", ["install"], {
|
|
26465
|
+
cwd: options.isMonorepo ? projectPath : targetCwd,
|
|
26466
|
+
stdio: options.silent ? "pipe" : "inherit",
|
|
26467
|
+
env: {
|
|
26468
|
+
...process.env,
|
|
26469
|
+
BUN_INSTALL_LINKER: "isolated"
|
|
26470
|
+
}
|
|
26471
|
+
});
|
|
26472
|
+
} catch (installError) {
|
|
26473
|
+
logger.warn(`Failed to install dependencies with Bun: ${installError.message}`);
|
|
26474
|
+
}
|
|
26460
26475
|
try {
|
|
26461
26476
|
await execa("bunx", ["shadcn@latest", "add", ...components], {
|
|
26462
26477
|
cwd: targetCwd,
|
|
26463
26478
|
stdio,
|
|
26464
26479
|
env: {
|
|
26465
26480
|
...process.env,
|
|
26466
|
-
BUN_INSTALL_LINKER: "isolated"
|
|
26481
|
+
BUN_INSTALL_LINKER: "isolated",
|
|
26482
|
+
npm_config_force: "true"
|
|
26467
26483
|
}
|
|
26468
26484
|
});
|
|
26469
26485
|
if (options.isMonorepo) {
|
|
@@ -26479,7 +26495,7 @@ async function installShadcnComponents(projectPath, components, options = {}) {
|
|
|
26479
26495
|
await updateComponentsIndex(join(targetCwd, "src/components"));
|
|
26480
26496
|
}
|
|
26481
26497
|
} catch (fallbackError) {
|
|
26482
|
-
logger.warn(`Could not install shadcn components automatically. You can install them manually with: cd ${targetCwd} && bunx shadcn@latest add ${components.join(" ")}`);
|
|
26498
|
+
logger.warn(`Could not install shadcn components automatically. You can install them manually with: cd ${targetCwd} && bun install && bunx shadcn@latest add ${components.join(" ")}`);
|
|
26483
26499
|
throw fallbackError;
|
|
26484
26500
|
}
|
|
26485
26501
|
}
|
|
@@ -26944,7 +26960,8 @@ async function setupShadcnMonorepo(projectPath, context) {
|
|
|
26944
26960
|
"./components/*": "./src/components/ui/*/index.ts",
|
|
26945
26961
|
"./lib/utils": "./src/lib/utils.ts",
|
|
26946
26962
|
"./hooks": "./src/hooks/index.ts",
|
|
26947
|
-
"./
|
|
26963
|
+
"./globals.css": "./src/styles/globals.css",
|
|
26964
|
+
"./postcss.config": "./postcss.config.mjs",
|
|
26948
26965
|
"./components/ui/*": "./src/components/ui/*/index.ts"
|
|
26949
26966
|
},
|
|
26950
26967
|
dependencies: {
|
|
@@ -27018,6 +27035,16 @@ export * from './hooks';
|
|
|
27018
27035
|
const theme = themes[baseColor] || themes.zinc;
|
|
27019
27036
|
const uiGlobalsCss = generateThemeCSS(theme, radius);
|
|
27020
27037
|
await writeFile(join(projectPath, "packages/ui/src/styles/globals.css"), uiGlobalsCss);
|
|
27038
|
+
const uiPostcssConfig = `/** @type {import('postcss-load-config').Config} */
|
|
27039
|
+
const config = {
|
|
27040
|
+
plugins: {
|
|
27041
|
+
'@tailwindcss/postcss': {},
|
|
27042
|
+
},
|
|
27043
|
+
};
|
|
27044
|
+
|
|
27045
|
+
export default config;
|
|
27046
|
+
`;
|
|
27047
|
+
await writeFile(join(projectPath, "packages/ui/postcss.config.mjs"), uiPostcssConfig);
|
|
27021
27048
|
const uiTsconfig = {
|
|
27022
27049
|
compilerOptions: {
|
|
27023
27050
|
target: "ES2017",
|
|
@@ -27069,10 +27096,77 @@ export * from './hooks';
|
|
|
27069
27096
|
}
|
|
27070
27097
|
};
|
|
27071
27098
|
await writeFile(join(appPath, "components.json"), JSON.stringify(appComponentsJson, null, 2));
|
|
27072
|
-
const
|
|
27073
|
-
|
|
27099
|
+
const layoutPath = join(appPath, "src/app/layout.tsx");
|
|
27100
|
+
if (await fileExists(layoutPath)) {
|
|
27101
|
+
let layoutContent = await Bun.file(layoutPath).text();
|
|
27102
|
+
layoutContent = layoutContent.replace(/import\s+['"]\.\/globals\.css['"];?\s*\n?/g, "");
|
|
27103
|
+
if (!layoutContent.includes(`${uiPackageName}/globals.css`) && !layoutContent.includes("@workspace/ui/globals.css")) {
|
|
27104
|
+
const importMatch = layoutContent.match(/^(import\s+.*?from\s+['"].*?['"];?\s*\n)/m);
|
|
27105
|
+
if (importMatch) {
|
|
27106
|
+
layoutContent = layoutContent.replace(/^(import\s+.*?from\s+['"].*?['"];?\s*\n)/m, `$1import '${uiPackageName}/globals.css'
|
|
27107
|
+
`);
|
|
27108
|
+
} else {
|
|
27109
|
+
layoutContent = `import '${uiPackageName}/globals.css'
|
|
27110
|
+
${layoutContent}`;
|
|
27111
|
+
}
|
|
27112
|
+
await writeFile(layoutPath, layoutContent);
|
|
27113
|
+
}
|
|
27114
|
+
} else {
|
|
27115
|
+
const layoutContent = `import type { Metadata } from 'next'
|
|
27116
|
+
import '${uiPackageName}/globals.css'
|
|
27117
|
+
|
|
27118
|
+
export const metadata: Metadata = {
|
|
27119
|
+
title: '${appName}',
|
|
27120
|
+
description: 'Built with bunkit',
|
|
27121
|
+
}
|
|
27122
|
+
|
|
27123
|
+
export default function RootLayout({
|
|
27124
|
+
children,
|
|
27125
|
+
}: {
|
|
27126
|
+
children: React.ReactNode
|
|
27127
|
+
}) {
|
|
27128
|
+
return (
|
|
27129
|
+
<html lang="en">
|
|
27130
|
+
<body>{children}</body>
|
|
27131
|
+
</html>
|
|
27132
|
+
)
|
|
27133
|
+
}
|
|
27074
27134
|
`;
|
|
27075
|
-
|
|
27135
|
+
await writeFile(layoutPath, layoutContent);
|
|
27136
|
+
}
|
|
27137
|
+
const postcssConfigPath = join(appPath, "postcss.config.mjs");
|
|
27138
|
+
const postcssConfig = `export { default } from '${uiPackageName}/postcss.config';
|
|
27139
|
+
`;
|
|
27140
|
+
await writeFile(postcssConfigPath, postcssConfig);
|
|
27141
|
+
const nextConfigPath = join(appPath, "next.config.ts");
|
|
27142
|
+
let nextConfigContent = "";
|
|
27143
|
+
if (await fileExists(nextConfigPath)) {
|
|
27144
|
+
nextConfigContent = await Bun.file(nextConfigPath).text();
|
|
27145
|
+
} else {
|
|
27146
|
+
nextConfigContent = `import type { NextConfig } from 'next';
|
|
27147
|
+
|
|
27148
|
+
const nextConfig: NextConfig = {
|
|
27149
|
+
/* config options here */
|
|
27150
|
+
};
|
|
27151
|
+
|
|
27152
|
+
export default nextConfig;
|
|
27153
|
+
`;
|
|
27154
|
+
}
|
|
27155
|
+
if (!nextConfigContent.includes("transpilePackages")) {
|
|
27156
|
+
if (nextConfigPath.endsWith(".ts")) {
|
|
27157
|
+
nextConfigContent = nextConfigContent.replace(/(const nextConfig: NextConfig = \{)/, `$1
|
|
27158
|
+
transpilePackages: ['${uiPackageName}'],`);
|
|
27159
|
+
} else {
|
|
27160
|
+
nextConfigContent = nextConfigContent.replace(/(const nextConfig = \{)/, `$1
|
|
27161
|
+
transpilePackages: ['${uiPackageName}'],`);
|
|
27162
|
+
}
|
|
27163
|
+
await writeFile(nextConfigPath, nextConfigContent);
|
|
27164
|
+
}
|
|
27165
|
+
const localGlobalsCssPath = join(appPath, "src/app/globals.css");
|
|
27166
|
+
if (await fileExists(localGlobalsCssPath)) {
|
|
27167
|
+
const { unlink } = await import("fs/promises");
|
|
27168
|
+
await unlink(localGlobalsCssPath);
|
|
27169
|
+
}
|
|
27076
27170
|
const packageJsonPath = join(appPath, "package.json");
|
|
27077
27171
|
let packageJson = {};
|
|
27078
27172
|
try {
|
|
@@ -27096,14 +27190,14 @@ export * from './hooks';
|
|
|
27096
27190
|
rootPackageJson.catalog = {};
|
|
27097
27191
|
}
|
|
27098
27192
|
const shadcnDependencies = {
|
|
27099
|
-
"@radix-ui/react-slot": "^1.
|
|
27193
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
27100
27194
|
"class-variance-authority": "^0.7.1",
|
|
27101
27195
|
clsx: "^2.1.1",
|
|
27102
|
-
"tailwind-merge": "^
|
|
27196
|
+
"tailwind-merge": "^3.3.1",
|
|
27103
27197
|
"lucide-react": "^0.468.0",
|
|
27104
|
-
"@types/react": "^
|
|
27105
|
-
"@types/react-dom": "^
|
|
27106
|
-
typescript: "^5.
|
|
27198
|
+
"@types/react": "^19.2.2",
|
|
27199
|
+
"@types/react-dom": "^19.2.2",
|
|
27200
|
+
typescript: "^5.9.3"
|
|
27107
27201
|
};
|
|
27108
27202
|
Object.assign(rootPackageJson.catalog, shadcnDependencies);
|
|
27109
27203
|
await writeFile(rootPackageJsonPath, JSON.stringify(rootPackageJson, null, 2));
|
|
@@ -32976,8 +33070,15 @@ async function createCommand2(preset, name, options) {
|
|
|
32976
33070
|
break;
|
|
32977
33071
|
}
|
|
32978
33072
|
s.message(`${source_default.cyan("\u2728")} Finalizing setup...`);
|
|
33073
|
+
if (config.install !== false) {
|
|
33074
|
+
s.message(`${source_default.cyan("\uD83D\uDCE6")} Installing dependencies...`);
|
|
33075
|
+
try {
|
|
33076
|
+
await installDependencies(projectPath);
|
|
33077
|
+
} catch (error) {
|
|
33078
|
+
s.message(`${source_default.yellow("\u26A0\uFE0F")} Dependency installation had issues, but continuing...`);
|
|
33079
|
+
}
|
|
33080
|
+
}
|
|
32979
33081
|
if (isEnterprise && config.uiLibrary === "shadcn" && config.install !== false) {
|
|
32980
|
-
await new Promise((resolve2) => setTimeout(resolve2, 1000));
|
|
32981
33082
|
s.message(`${source_default.cyan("\uD83E\uDDE9")} Installing default shadcn/ui components...`);
|
|
32982
33083
|
try {
|
|
32983
33084
|
await installDefaultShadcnComponents(projectPath, {
|
|
@@ -32986,7 +33087,7 @@ async function createCommand2(preset, name, options) {
|
|
|
32986
33087
|
});
|
|
32987
33088
|
} catch (error) {
|
|
32988
33089
|
s.message(`${source_default.yellow("\u26A0\uFE0F")} Could not install default components automatically`);
|
|
32989
|
-
s.message(`${source_default.dim(" You can install them manually:")} ${source_default.cyan("cd packages/ui && bunx shadcn@latest add button card")}`);
|
|
33090
|
+
s.message(`${source_default.dim(" You can install them manually:")} ${source_default.cyan("cd packages/ui && bun install && bunx shadcn@latest add button card")}`);
|
|
32990
33091
|
}
|
|
32991
33092
|
}
|
|
32992
33093
|
s.stop(`${source_default.green("\u2705")} Project ${source_default.bold(name)} created successfully!`);
|