diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig
index b052a11df6..b112d58999 100644
--- a/src/cli/create_command.zig
+++ b/src/cli/create_command.zig
@@ -272,7 +272,7 @@ pub const CreateCommand = struct {
var example_tag = Example.Tag.unknown;
- var unsupported_packages = UnsupportedPackages{};
+ // var unsupported_packages = UnsupportedPackages{};
const template = brk: {
var positional = positionals[0];
@@ -753,55 +753,55 @@ pub const CreateCommand = struct {
}
}
- const Needs = struct {
- bun_bun_for_nextjs: bool = false,
- bun_macro_relay: bool = false,
- bun_macro_relay_dependency: bool = false,
- bun_framework_next: bool = false,
- react_refresh: bool = false,
- };
- var needs = Needs{};
- var has_relay = false;
- var has_bun_framework_next = false;
- var has_react_refresh = false;
- var has_bun_macro_relay = false;
- var has_react = false;
- var has_react_scripts = false;
+ // const Needs = struct {
+ // bun_bun_for_nextjs: bool = false,
+ // bun_macro_relay: bool = false,
+ // bun_macro_relay_dependency: bool = false,
+ // bun_framework_next: bool = false,
+ // react_refresh: bool = false,
+ // };
+ // var needs = Needs{};
+ // var has_relay = false;
+ // var has_bun_framework_next = false;
+ // var has_react_refresh = false;
+ // var has_bun_macro_relay = false;
+ // var has_react = false;
+ // var has_react_scripts = false;
- const Prune = struct {
- pub const packages = ComptimeStringMap(void, .{
- .{ "@parcel/babel-preset", {} },
- .{ "@parcel/core", {} },
- .{ "@swc/cli", {} },
- .{ "@swc/core", {} },
- .{ "@webpack/cli", {} },
- .{ "react-scripts", {} },
- .{ "webpack-cli", {} },
- .{ "webpack", {} },
+ // const Prune = struct {
+ // pub const packages = ComptimeStringMap(void, .{
+ // .{ "@parcel/babel-preset", {} },
+ // .{ "@parcel/core", {} },
+ // .{ "@swc/cli", {} },
+ // .{ "@swc/core", {} },
+ // .{ "@webpack/cli", {} },
+ // .{ "react-scripts", {} },
+ // .{ "webpack-cli", {} },
+ // .{ "webpack", {} },
- // one of cosmic config's imports breaks stuff
- .{ "cosmiconfig", {} },
- });
- pub var prune_count: u16 = 0;
+ // // one of cosmic config's imports breaks stuff
+ // .{ "cosmiconfig", {} },
+ // });
+ // pub var prune_count: u16 = 0;
- pub fn prune(list: []js_ast.G.Property) []js_ast.G.Property {
- var i: usize = 0;
- var out_i: usize = 0;
- while (i < list.len) : (i += 1) {
- const key = list[i].key.?.data.e_string.data;
+ // pub fn prune(list: []js_ast.G.Property) []js_ast.G.Property {
+ // var i: usize = 0;
+ // var out_i: usize = 0;
+ // while (i < list.len) : (i += 1) {
+ // const key = list[i].key.?.data.e_string.data;
- const do_prune = packages.has(key);
- prune_count += @as(u16, @intCast(@intFromBool(do_prune)));
+ // const do_prune = packages.has(key);
+ // prune_count += @as(u16, @intCast(@intFromBool(do_prune)));
- if (!do_prune) {
- list[out_i] = list[i];
- out_i += 1;
- }
- }
+ // if (!do_prune) {
+ // list[out_i] = list[i];
+ // out_i += 1;
+ // }
+ // }
- return list[0..out_i];
- }
- };
+ // return list[0..out_i];
+ // }
+ // };
var dev_dependencies: ?js_ast.Expr = null;
var dependencies: ?js_ast.Expr = null;
@@ -810,20 +810,20 @@ pub const CreateCommand = struct {
const property = q.expr;
if (property.data == .e_object and property.data.e_object.properties.len > 0) {
- unsupported_packages.update(property);
+ // unsupported_packages.update(property);
- has_react_scripts = has_react_scripts or property.hasAnyPropertyNamed(&.{"react-scripts"});
- has_relay = has_relay or property.hasAnyPropertyNamed(&.{ "react-relay", "relay-runtime", "babel-plugin-relay" });
+ // has_react_scripts = has_react_scripts or property.hasAnyPropertyNamed(&.{"react-scripts"});
+ // has_relay = has_relay or property.hasAnyPropertyNamed(&.{ "react-relay", "relay-runtime", "babel-plugin-relay" });
- property.data.e_object.properties = js_ast.G.Property.List.init(Prune.prune(property.data.e_object.properties.slice()));
+ // property.data.e_object.properties = js_ast.G.Property.List.init(Prune.prune(property.data.e_object.properties.slice()));
if (property.data.e_object.properties.len > 0) {
has_dependencies = true;
dev_dependencies = q.expr;
- has_bun_framework_next = has_bun_framework_next or property.hasAnyPropertyNamed(&.{"bun-framework-next"});
- has_react = has_react or property.hasAnyPropertyNamed(&.{ "react", "react-dom", "react-relay", "@emotion/react" });
- has_bun_macro_relay = has_bun_macro_relay or property.hasAnyPropertyNamed(&.{"bun-macro-relay"});
- has_react_refresh = has_react_refresh or property.hasAnyPropertyNamed(&.{"react-refresh"});
+ // has_bun_framework_next = has_bun_framework_next or property.hasAnyPropertyNamed(&.{"bun-framework-next"});
+ // has_react = has_react or property.hasAnyPropertyNamed(&.{ "react", "react-dom", "react-relay", "@emotion/react" });
+ // has_bun_macro_relay = has_bun_macro_relay or property.hasAnyPropertyNamed(&.{"bun-macro-relay"});
+ // has_react_refresh = has_react_refresh or property.hasAnyPropertyNamed(&.{"react-refresh"});
}
}
}
@@ -832,101 +832,102 @@ pub const CreateCommand = struct {
const property = q.expr;
if (property.data == .e_object and property.data.e_object.properties.len > 0) {
- unsupported_packages.update(property);
+ // unsupported_packages.update(property);
- has_react_scripts = has_react_scripts or property.hasAnyPropertyNamed(&.{"react-scripts"});
- has_relay = has_relay or property.hasAnyPropertyNamed(&.{ "react-relay", "relay-runtime", "babel-plugin-relay" });
- property.data.e_object.properties = js_ast.G.Property.List.init(Prune.prune(property.data.e_object.properties.slice()));
+ // has_react_scripts = has_react_scripts or property.hasAnyPropertyNamed(&.{"react-scripts"});
+ // has_relay = has_relay or property.hasAnyPropertyNamed(&.{ "react-relay", "relay-runtime", "babel-plugin-relay" });
+ // property.data.e_object.properties = js_ast.G.Property.List.init(Prune.prune(property.data.e_object.properties.slice()));
+ property.data.e_object.properties = js_ast.G.Property.List.init(property.data.e_object.properties.slice());
if (property.data.e_object.properties.len > 0) {
has_dependencies = true;
dependencies = q.expr;
- if (property.asProperty("next")) |next_q| {
- is_nextjs = true;
- needs.bun_bun_for_nextjs = true;
+ // if (property.asProperty("next")) |next_q| {
+ // is_nextjs = true;
+ // needs.bun_bun_for_nextjs = true;
- next_q.expr.data.e_string.data = constStrToU8(target_nextjs_version);
- }
+ // next_q.expr.data.e_string.data = constStrToU8(target_nextjs_version);
+ // }
- has_bun_framework_next = has_bun_framework_next or property.hasAnyPropertyNamed(&.{"bun-framework-next"});
- has_react = has_react or is_nextjs or property.hasAnyPropertyNamed(&.{ "react", "react-dom", "react-relay", "@emotion/react" });
- has_react_refresh = has_react_refresh or property.hasAnyPropertyNamed(&.{"react-refresh"});
- has_bun_macro_relay = has_bun_macro_relay or property.hasAnyPropertyNamed(&.{"bun-macro-relay"});
+ // has_bun_framework_next = has_bun_framework_next or property.hasAnyPropertyNamed(&.{"bun-framework-next"});
+ // has_react = has_react or is_nextjs or property.hasAnyPropertyNamed(&.{ "react", "react-dom", "react-relay", "@emotion/react" });
+ // has_react_refresh = has_react_refresh or property.hasAnyPropertyNamed(&.{"react-refresh"});
+ // has_bun_macro_relay = has_bun_macro_relay or property.hasAnyPropertyNamed(&.{"bun-macro-relay"});
}
}
}
- needs.bun_macro_relay = !has_bun_macro_relay and has_relay;
- needs.react_refresh = !has_react_refresh and has_react;
- needs.bun_framework_next = is_nextjs and !has_bun_framework_next;
- needs.bun_bun_for_nextjs = is_nextjs;
- needs.bun_macro_relay_dependency = needs.bun_macro_relay;
- var bun_bun_for_react_scripts = false;
+ // needs.bun_macro_relay = !has_bun_macro_relay and has_relay;
+ // needs.react_refresh = !has_react_refresh and has_react;
+ // needs.bun_framework_next = is_nextjs and !has_bun_framework_next;
+ // needs.bun_bun_for_nextjs = is_nextjs;
+ // needs.bun_macro_relay_dependency = needs.bun_macro_relay;
+ // var bun_bun_for_react_scripts = false;
- var bun_macros_prop: ?js_ast.Expr = null;
- var bun_prop: ?js_ast.Expr = null;
- var bun_relay_prop: ?js_ast.Expr = null;
+ // var bun_macros_prop: ?js_ast.Expr = null;
+ // var bun_prop: ?js_ast.Expr = null;
+ // var bun_relay_prop: ?js_ast.Expr = null;
- var needs_bun_prop = needs.bun_macro_relay or has_bun_macro_relay;
- var needs_bun_macros_prop = needs_bun_prop;
+ // var needs_bun_prop = needs.bun_macro_relay or has_bun_macro_relay;
+ // var needs_bun_macros_prop = needs_bun_prop;
- if (needs_bun_macros_prop) {
- if (package_json_expr.asProperty("bun")) |bun_| {
- needs_bun_prop = false;
- bun_prop = bun_.expr;
- if (bun_.expr.asProperty("macros")) |macros_q| {
- bun_macros_prop = macros_q.expr;
- needs_bun_macros_prop = false;
- if (macros_q.expr.asProperty("react-relay")) |react_relay_q| {
- bun_relay_prop = react_relay_q.expr;
- needs.bun_macro_relay = react_relay_q.expr.asProperty("graphql") == null;
- }
+ // if (needs_bun_macros_prop) {
+ // if (package_json_expr.asProperty("bun")) |bun_| {
+ // needs_bun_prop = false;
+ // bun_prop = bun_.expr;
+ // if (bun_.expr.asProperty("macros")) |macros_q| {
+ // bun_macros_prop = macros_q.expr;
+ // needs_bun_macros_prop = false;
+ // if (macros_q.expr.asProperty("react-relay")) |react_relay_q| {
+ // bun_relay_prop = react_relay_q.expr;
+ // needs.bun_macro_relay = react_relay_q.expr.asProperty("graphql") == null;
+ // }
- if (macros_q.expr.asProperty("babel-plugin-relay/macro")) |react_relay_q| {
- bun_relay_prop = react_relay_q.expr;
- needs.bun_macro_relay = react_relay_q.expr.asProperty("graphql") == null;
- }
- }
- }
- }
+ // if (macros_q.expr.asProperty("babel-plugin-relay/macro")) |react_relay_q| {
+ // bun_relay_prop = react_relay_q.expr;
+ // needs.bun_macro_relay = react_relay_q.expr.asProperty("graphql") == null;
+ // }
+ // }
+ // }
+ // }
- if (Prune.prune_count > 0) {
- Output.prettyErrorln("
") orelse break :bail; + // var body_closing_tag: usize = std.mem.lastIndexOf(u8, public_index_file_contents, "") orelse break :bail; - var public_index_file_out = std.ArrayList(u8).initCapacity(ctx.allocator, public_index_file_contents.len) catch break :bail; - var html_writer = public_index_file_out.writer(); + // var public_index_file_out = std.ArrayList(u8).initCapacity(ctx.allocator, public_index_file_contents.len) catch break :bail; + // var html_writer = public_index_file_out.writer(); - _ = html_writer.writeAll(public_index_file_contents[0..body_closing_tag]) catch break :bail; + // _ = html_writer.writeAll(public_index_file_contents[0..body_closing_tag]) catch break :bail; - create_react_app_entry_point_path = std.fmt.allocPrint( - ctx.allocator, - "./{s}", + // create_react_app_entry_point_path = std.fmt.allocPrint( + // ctx.allocator, + // "./{s}", - .{ - std.mem.trimLeft( - u8, - entry_point_path[destination.len..], - "/", - ), - }, - ) catch break :bail; + // .{ + // std.mem.trimLeft( + // u8, + // entry_point_path[destination.len..], + // "/", + // ), + // }, + // ) catch break :bail; - html_writer.print( - "\n{s}", - .{ - create_react_app_entry_point_path[2..], - public_index_file_contents[body_closing_tag..], - }, - ) catch break :bail; + // html_writer.print( + // "\n{s}", + // .{ + // create_react_app_entry_point_path[2..], + // public_index_file_contents[body_closing_tag..], + // }, + // ) catch break :bail; - var outfile = std.mem.replaceOwned(u8, ctx.allocator, public_index_file_out.items, "%PUBLIC_URL%", "") catch break :bail; + // var outfile = std.mem.replaceOwned(u8, ctx.allocator, public_index_file_out.items, "%PUBLIC_URL%", "") catch break :bail; - // don't do this actually - // it completely breaks when there is more than one CSS file loaded - // // bonus: check for an index.css file - // // inject it into the .html file statically if the file exists but isn't already in - // inject_css: { - // const head_i: usize = std.mem.indexOf(u8, outfile, "
") orelse break :inject_css; - // if (std.mem.indexOf(u8, outfile, "/src/index.css") != null) break :inject_css; + // // don't do this actually + // // it completely breaks when there is more than one CSS file loaded + // // // bonus: check for an index.css file + // // // inject it into the .html file statically if the file exists but isn't already in + // // inject_css: { + // // const head_i: usize = std.mem.indexOf(u8, outfile, "
") orelse break :inject_css; + // // if (std.mem.indexOf(u8, outfile, "/src/index.css") != null) break :inject_css; - // bun.copy(u8, bun_path_buf[destination.len + "/src/index".len ..], ".css"); - // var index_css_file_path = bun_path_buf[0 .. destination.len + "/src/index.css".len]; - // std.fs.accessAbsolute(index_css_file_path, .{}) catch break :inject_css; - // var list = std.ArrayList(u8).fromOwnedSlice(ctx.allocator, outfile); - // list.insertSlice(head_i + "
".len, "\n") catch break :inject_css; - // outfile =try list.toOwnedSlice(); - // } + // // bun.copy(u8, bun_path_buf[destination.len + "/src/index".len ..], ".css"); + // // var index_css_file_path = bun_path_buf[0 .. destination.len + "/src/index.css".len]; + // // std.fs.accessAbsolute(index_css_file_path, .{}) catch break :inject_css; + // // var list = std.ArrayList(u8).fromOwnedSlice(ctx.allocator, outfile); + // // list.insertSlice(head_i + "
".len, "\n") catch break :inject_css;
+ // // outfile =try list.toOwnedSlice();
+ // // }
- public_index_html_file.pwriteAll(outfile, 0) catch break :bail;
- std.os.ftruncate(public_index_html_file.handle, outfile.len + 1) catch break :bail;
- bun_bun_for_react_scripts = true;
- is_create_react_app = true;
- Output.prettyln("