Skip to content

Commit

Permalink
slightly better
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Feb 7, 2025
1 parent 6338cd0 commit 7feda1a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
35 changes: 16 additions & 19 deletions src/create/SourceFileProjectGenerator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ pub fn generate(_: Command.Context, example_tag: Example.Tag, entry_point: strin
}

const uses_tailwind = has_tailwind_in_dependencies or needs_to_inject_tailwind;
// Add react-dom if react is used

if (result.dependencies.contains("react")) {
try result.dependencies.insert("react-dom");
if (needs_to_inject_shadcn_ui) {
// Use react 18 instead of 19 if shadcn is in use.
_ = result.dependencies.swapRemove("react");
_ = result.dependencies.swapRemove("react-dom");
try result.dependencies.insert("react@^18");
try result.dependencies.insert("react-dom@^18");
} else {
// Add react-dom if react is used
try result.dependencies.insert("react-dom");
}
}

// Choose template based on dependencies and example type
Expand Down Expand Up @@ -166,7 +175,6 @@ fn generateFiles(allocator: std.mem.Allocator, entry_point: string, result: *Bun
}
},
.err => |err| {
log.writeInitialMessage();
Output.err(err, "failed to create components.json", .{});
Global.crash();
},
Expand All @@ -183,7 +191,6 @@ fn generateFiles(allocator: std.mem.Allocator, entry_point: string, result: *Bun
}
},
.err => |err| {
log.writeInitialMessage();
Output.err(err, "failed to create package.json", .{});
Global.crash();
},
Expand All @@ -199,7 +206,6 @@ fn generateFiles(allocator: std.mem.Allocator, entry_point: string, result: *Bun
}
},
.err => |err| {
log.writeInitialMessage();
Output.err(err, "failed to create tsconfig.json", .{});
Global.crash();
},
Expand All @@ -215,7 +221,6 @@ fn generateFiles(allocator: std.mem.Allocator, entry_point: string, result: *Bun
}
},
.err => |err| {
log.writeInitialMessage();
Output.err(err, "failed to create bunfig.toml", .{});
Global.crash();
},
Expand All @@ -232,7 +237,6 @@ fn generateFiles(allocator: std.mem.Allocator, entry_point: string, result: *Bun
}
},
.err => |err| {
log.writeInitialMessage();
Output.err(err, "failed to create {s}", .{file_name});
Global.crash();
},
Expand Down Expand Up @@ -588,15 +592,8 @@ const Template = union(Tag) {
template: Tag,

pub fn file(this: *Logger, name: []const u8) void {
this.writeInitialMessage();

Output.prettyln("<r><d>+<r> {s}\n", .{name});
}

pub fn writeInitialMessage(this: *Logger) void {
if (this.has_written_initial_message) return;
this.has_written_initial_message = true;
Output.prettyln("\n<r>✨ <b><cyan>{s}<r>\n", .{this.template.label()});
Output.prettyln("<r><green>create<r> {s}\n", .{name});
}

pub fn ifNew(this: *Logger) void {
Expand All @@ -605,13 +602,13 @@ const Template = union(Tag) {
Output.prettyln(
\\✨ <b>{s}<r> project configured
\\
\\<b><cyan>Development<r> - <d>frontend dev server with hot reload<r>
\\<b><cyan>Development<r><d> - frontend dev server with hot reload<r>
\\
\\<b><d><cyan>$<r> <cyan><b>bun dev<r>
\\ <cyan><b>bun dev<r>
\\
\\<b><green>Production - <d>build optimized assets<r>
\\<b><green>Production<r><d> - build optimized assets<r>
\\
\\<b><d><green>$<r> <green><b>bun run build<r>
\\ <green><b>bun run build<r>
\\
\\<blue>Happy bunning! 🐇<r>
\\
Expand Down
4 changes: 2 additions & 2 deletions src/create/projects/react-shadcn-spa/components.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
Expand All @@ -17,5 +17,5 @@
"lib": "@/lib",
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
"iconLibrary": "radix"
}

0 comments on commit 7feda1a

Please sign in to comment.