create-bearnie 0.4.4 → 0.5.0
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 +45 -22
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -13,6 +13,19 @@ var link = (text, url) => `\x1B]8;;${url}\x07${pc.cyan(text)}\x1B]8;;\x07`;
|
|
|
13
13
|
function parseFullArg() {
|
|
14
14
|
return process.argv.includes("--full");
|
|
15
15
|
}
|
|
16
|
+
function detectPackageManager() {
|
|
17
|
+
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
18
|
+
if (userAgent.startsWith("pnpm")) return "pnpm";
|
|
19
|
+
if (userAgent.startsWith("yarn")) return "yarn";
|
|
20
|
+
if (userAgent.startsWith("bun")) return "bun";
|
|
21
|
+
return "npm";
|
|
22
|
+
}
|
|
23
|
+
var PM_COMMANDS = {
|
|
24
|
+
npm: { install: "npm install", dev: "npm run dev", dlx: "npx" },
|
|
25
|
+
pnpm: { install: "pnpm install", dev: "pnpm dev", dlx: "pnpm dlx" },
|
|
26
|
+
yarn: { install: "yarn", dev: "yarn dev", dlx: "yarn dlx" },
|
|
27
|
+
bun: { install: "bun install", dev: "bun run dev", dlx: "bunx" }
|
|
28
|
+
};
|
|
16
29
|
var REGISTRY_URL = process.env.BEARNIE_REGISTRY_URL || "https://bearnie.dev/registry";
|
|
17
30
|
var REGISTRY_PATH = process.env.BEARNIE_REGISTRY_PATH;
|
|
18
31
|
var BEARNIE_CONFIG = {
|
|
@@ -22,15 +35,25 @@ var BEARNIE_CONFIG = {
|
|
|
22
35
|
tailwindConfig: "tailwind.config.mjs",
|
|
23
36
|
typescript: true
|
|
24
37
|
};
|
|
25
|
-
var
|
|
38
|
+
var FALLBACK_UTILITY_NAMES = [
|
|
39
|
+
"cn",
|
|
26
40
|
"focus-trap",
|
|
27
41
|
"ui-runtime-loader",
|
|
28
42
|
"ui-runtime-boot",
|
|
43
|
+
"ui-runtime-dialog",
|
|
29
44
|
"ui-runtime-disclosure-triggers",
|
|
45
|
+
"ui-runtime-dropdown-menu",
|
|
30
46
|
"ui-runtime-popover",
|
|
31
47
|
"ui-runtime-command",
|
|
32
|
-
"ui-runtime-combobox"
|
|
48
|
+
"ui-runtime-combobox",
|
|
49
|
+
"ui-runtime-tabs"
|
|
33
50
|
];
|
|
51
|
+
var DEP_VERSIONS = {
|
|
52
|
+
clsx: "^2.1.1",
|
|
53
|
+
"tailwind-merge": "^3.6.0",
|
|
54
|
+
"keen-slider": "^6.8.6",
|
|
55
|
+
"@hugeicons/core-free-icons": "^4.2.3"
|
|
56
|
+
};
|
|
34
57
|
function resolveInstallPath(targetDir, filePath, type) {
|
|
35
58
|
if (type === "utility" || filePath.startsWith("utils/")) {
|
|
36
59
|
return path.join(targetDir, "src/utils", filePath.replace(/^utils\//, ""));
|
|
@@ -148,25 +171,19 @@ ${fullInstall ? ` ${pc.dim("Full install: including all components")}
|
|
|
148
171
|
`);
|
|
149
172
|
await fs.ensureDir(path.join(targetDir, "src", "components", "bearnie"));
|
|
150
173
|
await fs.ensureDir(path.join(targetDir, "src", "utils"));
|
|
151
|
-
|
|
174
|
+
const registryIndex = await fetchRegistryIndex();
|
|
175
|
+
const npmDependencies = /* @__PURE__ */ new Set(["clsx", "tailwind-merge"]);
|
|
176
|
+
const utilityNames = registryIndex.utilities?.length ? registryIndex.utilities.map((utility) => utility.name) : FALLBACK_UTILITY_NAMES;
|
|
177
|
+
for (const utilityName of utilityNames) {
|
|
152
178
|
const utility = await fetchRegistryEntry(utilityName);
|
|
153
179
|
if (utility?.files) {
|
|
154
180
|
await writeRegistryFiles(targetDir, utility);
|
|
181
|
+
utility.dependencies?.forEach((dep) => npmDependencies.add(dep));
|
|
155
182
|
console.log(` ${pc.green("\u2713")} Added ${utilityName} utility`);
|
|
156
183
|
} else {
|
|
157
184
|
console.log(` ${pc.yellow("!")} Failed to fetch ${utilityName} utility`);
|
|
158
185
|
}
|
|
159
186
|
}
|
|
160
|
-
const cnContent = `import { clsx, type ClassValue } from "clsx";
|
|
161
|
-
import { twMerge } from "tailwind-merge";
|
|
162
|
-
|
|
163
|
-
export function cn(...inputs: ClassValue[]) {
|
|
164
|
-
return twMerge(clsx(inputs));
|
|
165
|
-
}
|
|
166
|
-
`;
|
|
167
|
-
await fs.writeFile(path.join(targetDir, "src", "utils", "cn.ts"), cnContent);
|
|
168
|
-
console.log(` ${pc.green("\u2713")} Added cn utility`);
|
|
169
|
-
const registryIndex = await fetchRegistryIndex();
|
|
170
187
|
const componentNames = registryIndex.components.map((component) => component.name).filter((name) => name !== "styles" && name !== "barrel");
|
|
171
188
|
let installed = 0;
|
|
172
189
|
let failed = 0;
|
|
@@ -174,6 +191,7 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
174
191
|
const component = await fetchRegistryEntry(componentName);
|
|
175
192
|
if (component?.files) {
|
|
176
193
|
await writeRegistryFiles(targetDir, component);
|
|
194
|
+
component.dependencies?.forEach((dep) => npmDependencies.add(dep));
|
|
177
195
|
installed++;
|
|
178
196
|
process.stdout.write(
|
|
179
197
|
`\r ${pc.green("\u2713")} Installed ${installed}/${componentNames.length} components`
|
|
@@ -195,13 +213,17 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
195
213
|
}
|
|
196
214
|
const pkgPath2 = path.join(targetDir, "package.json");
|
|
197
215
|
const pkg2 = await fs.readJson(pkgPath2);
|
|
216
|
+
const addedDeps = Object.fromEntries(
|
|
217
|
+
[...npmDependencies].sort().map((dep) => [dep, DEP_VERSIONS[dep] ?? "latest"])
|
|
218
|
+
);
|
|
198
219
|
pkg2.dependencies = {
|
|
199
220
|
...pkg2.dependencies,
|
|
200
|
-
|
|
201
|
-
"tailwind-merge": "^3.3.0"
|
|
221
|
+
...addedDeps
|
|
202
222
|
};
|
|
203
223
|
await fs.writeJson(pkgPath2, pkg2, { spaces: 2 });
|
|
204
|
-
console.log(
|
|
224
|
+
console.log(
|
|
225
|
+
` ${pc.green("\u2713")} Added ${Object.keys(addedDeps).length} npm dependencies (${Object.keys(addedDeps).join(", ")})`
|
|
226
|
+
);
|
|
205
227
|
}
|
|
206
228
|
await fs.writeFile(
|
|
207
229
|
path.join(targetDir, ".gitignore"),
|
|
@@ -229,6 +251,7 @@ Thumbs.db
|
|
|
229
251
|
`
|
|
230
252
|
);
|
|
231
253
|
console.log(` ${pc.green("\u2713")} Created project files`);
|
|
254
|
+
const pmCommands = PM_COMMANDS[detectPackageManager()];
|
|
232
255
|
if (fullInstall) {
|
|
233
256
|
console.log(`
|
|
234
257
|
${pc.green("Done!")} Your Bearnie project is ready with all components.
|
|
@@ -236,8 +259,8 @@ Thumbs.db
|
|
|
236
259
|
${pc.bold("Next steps:")}
|
|
237
260
|
|
|
238
261
|
${pc.dim("1.")} cd ${pc.cyan(finalName)}
|
|
239
|
-
${pc.dim("2.")}
|
|
240
|
-
${pc.dim("3.")}
|
|
262
|
+
${pc.dim("2.")} ${pmCommands.install}
|
|
263
|
+
${pc.dim("3.")} ${pmCommands.dev}
|
|
241
264
|
|
|
242
265
|
${pc.dim("All components are in")} ${pc.cyan("src/components/bearnie/")}
|
|
243
266
|
${pc.dim("Import from")} ${pc.cyan("@/components/bearnie")} ${pc.dim("via")} ${pc.cyan("index.ts")}
|
|
@@ -253,12 +276,12 @@ Thumbs.db
|
|
|
253
276
|
${pc.bold("Next steps:")}
|
|
254
277
|
|
|
255
278
|
${pc.dim("1.")} cd ${pc.cyan(finalName)}
|
|
256
|
-
${pc.dim("2.")}
|
|
257
|
-
${pc.dim("3.")}
|
|
258
|
-
${pc.dim("4.")}
|
|
279
|
+
${pc.dim("2.")} ${pmCommands.install}
|
|
280
|
+
${pc.dim("3.")} ${pmCommands.dlx} bearnie add button card
|
|
281
|
+
${pc.dim("4.")} ${pmCommands.dev}
|
|
259
282
|
|
|
260
283
|
${pc.dim("Or use")} ${pc.cyan("--full")} ${pc.dim("to include all components:")}
|
|
261
|
-
|
|
284
|
+
${pmCommands.dlx} create-bearnie my-app --full
|
|
262
285
|
|
|
263
286
|
${pc.dim("Browse components at")} ${link("bearnie.dev/docs/components", "https://bearnie.dev/docs/components")}
|
|
264
287
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-bearnie",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Create a new Astro project with Bearnie UI components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/fs-extra": "^11.0.4",
|
|
26
|
-
"@types/node": "^
|
|
26
|
+
"@types/node": "^22.10.0",
|
|
27
27
|
"@types/prompts": "^2.4.9",
|
|
28
28
|
"tsup": "^8.1.0",
|
|
29
29
|
"typescript": "^5.7.3"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=22.12.0"
|
|
33
33
|
},
|
|
34
34
|
"author": "Michael Andreuzza",
|
|
35
35
|
"repository": {
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"url": "https://github.com/michael-andreuzza/bearnie.git",
|
|
38
38
|
"directory": "packages/create-bearnie"
|
|
39
39
|
},
|
|
40
|
+
"homepage": "https://bearnie.dev",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/michael-andreuzza/bearnie/issues"
|
|
43
|
+
},
|
|
40
44
|
"keywords": [
|
|
41
45
|
"create",
|
|
42
46
|
"bearnie",
|