aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-09-07 04:58:44 -0700
committerGravatar GitHub <noreply@github.com> 2023-09-07 04:58:44 -0700
commit57a06745a48093c25d0f4729ccea41a918d6427d (patch)
treeac2568d5c98918d6364d2a9667c164cd3f3b3867 /src/cli
parent4360ec83b4146e15344b304573795f084f86a7c2 (diff)
downloadbun-57a06745a48093c25d0f4729ccea41a918d6427d.tar.gz
bun-57a06745a48093c25d0f4729ccea41a918d6427d.tar.zst
bun-57a06745a48093c25d0f4729ccea41a918d6427d.zip
Progress for Next.js (#4468)
* L * ipc * asdfghjkl * dfghjk * it works! * types * patches for next.js * sdfghj * wsdfgn,./ * this * yolo * okay loser * asdfghjk * add some more APIs * MESS * sdfghjkl * remove native events from streams * stuff * remove lazy(primordials) test * debugging * okay * less fake extensions object * fix `Buffer.toString()` args logic * fix deserialize * make tests work * add test for `Buffer.toString` args * Update server.zig * remove test * update test * Update spawn-streaming-stdin.test.ts * fix linux build * Update fs.test.ts * cli message improvements * dfshaj * Fix fs.watch bug maybe? * remove --------- Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/bunx_command.zig26
-rw-r--r--src/cli/create_command.zig2
-rw-r--r--src/cli/discord_command.zig2
-rw-r--r--src/cli/init_command.zig2
-rw-r--r--src/cli/package_manager_command.zig4
-rw-r--r--src/cli/test_command.zig11
6 files changed, 32 insertions, 15 deletions
diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig
index 9bf7e1d11..0a161d102 100644
--- a/src/cli/bunx_command.zig
+++ b/src/cli/bunx_command.zig
@@ -15,6 +15,28 @@ const Run = @import("./run_command.zig").RunCommand;
pub const BunxCommand = struct {
var path_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+ /// clones the string
+ pub fn addCreatePrefix(allocator: std.mem.Allocator, input: []const u8) ![:0]const u8 {
+ const prefixLength = "create-".len;
+
+ if (input.len == 0) return try allocator.dupeZ(u8, input);
+
+ var new_str = try allocator.allocSentinel(u8, input.len + prefixLength, 0);
+ if (input[0] == '@') {
+ if (strings.indexAnyComptime(input, "/")) |index| {
+ @memcpy(new_str[0..index], input[0..index]);
+ @memcpy(new_str[index .. index + prefixLength], "create-");
+ @memcpy(new_str[index + prefixLength ..], input[index..]);
+ return new_str;
+ }
+ }
+
+ @memcpy(new_str[0..prefixLength], "create-");
+ @memcpy(new_str[prefixLength..], input);
+
+ return new_str;
+ }
+
fn getBinNameFromSubpath(bundler: *bun.Bundler, dir_fd: std.os.fd_t, subpath_z: [:0]const u8) ![]const u8 {
const target_package_json_fd = try std.os.openatZ(dir_fd, subpath_z, std.os.O.RDONLY, 0);
const target_package_json = std.fs.File{ .handle = target_package_json_fd };
@@ -137,15 +159,13 @@ pub const BunxCommand = struct {
Global.exit(1);
}
- pub fn exec(ctx: bun.CLI.Command.Context) !void {
+ pub fn exec(ctx: bun.CLI.Command.Context, argv: [][*:0]const u8) !void {
var requests_buf = bun.PackageManager.UpdateRequest.Array.init(0) catch unreachable;
var run_in_bun = ctx.debug.run_in_bun;
var passthrough_list = try std.ArrayList(string).initCapacity(ctx.allocator, bun.argv().len -| 1);
var package_name_for_update_request = [1]string{""};
{
- var argv = bun.argv()[1..];
-
var found_subcommand_name = false;
for (argv) |positional_| {
diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig
index 8264bf771..d661e3aab 100644
--- a/src/cli/create_command.zig
+++ b/src/cli/create_command.zig
@@ -1665,7 +1665,7 @@ pub const CreateCommand = struct {
child.stderr_behavior = .Inherit;
const open = @import("../open.zig");
- open.openURL("http://localhost:3000/") catch {};
+ open.openURL("http://localhost:3000/");
try child.spawn();
_ = child.wait() catch {};
diff --git a/src/cli/discord_command.zig b/src/cli/discord_command.zig
index 9df5c4958..46b3b3704 100644
--- a/src/cli/discord_command.zig
+++ b/src/cli/discord_command.zig
@@ -14,6 +14,6 @@ const open = @import("../open.zig");
pub const DiscordCommand = struct {
const discord_url: string = "https://bun.sh/discord";
pub fn exec(_: std.mem.Allocator) !void {
- try open.openURL(discord_url);
+ open.openURL(discord_url);
}
};
diff --git a/src/cli/init_command.zig b/src/cli/init_command.zig
index 8d65461a7..0606500ac 100644
--- a/src/cli/init_command.zig
+++ b/src/cli/init_command.zig
@@ -221,7 +221,7 @@ pub const InitCommand = struct {
};
if (!auto_yes) {
- Output.prettyln("<r><b>bun init<r> helps you get started with a minimal project and tries to guess sensible defaults. <d>Press ^C anytime to quit<r>\n\n", .{});
+ Output.prettyln("<r><b>bun init<r> helps you get started with a minimal project and tries to guess sensible defaults.\n<d>Press ^C anytime to quit<r>\n\n", .{});
Output.flush();
fields.name = try normalizePackageName(alloc, try prompt(
diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig
index cb03b9e3f..a70dec020 100644
--- a/src/cli/package_manager_command.zig
+++ b/src/cli/package_manager_command.zig
@@ -247,7 +247,7 @@ pub const PackageManagerCommand = struct {
}
Output.prettyln(
- \\bun pm - package manager related commands
+ \\<b><blue>bun pm<r>: package manager related commands
\\
\\ bun pm <b>bin<r> print the path to bin folder
\\ bun pm <b>-g bin<r> print the <b>global<r> path to bin folder
@@ -259,6 +259,8 @@ pub const PackageManagerCommand = struct {
\\ bun pm <b>cache<r> print the path to the cache folder
\\ bun pm <b>cache rm<r> clear the cache
\\
+ \\Learn more about these at <magenta>https://bun.sh/docs/install/utilities<r>
+ \\
, .{});
if (subcommand.len > 0) {
diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig
index bbbd36dc7..75ac87e5d 100644
--- a/src/cli/test_command.zig
+++ b/src/cli/test_command.zig
@@ -549,8 +549,6 @@ const Scanner = struct {
pub const TestCommand = struct {
pub const name = "test";
- pub const old_name = "wiptest";
-
pub const CodeCoverageOptions = struct {
skip_test_files: bool = !Environment.allow_assert,
fractions: bun.sourcemap.CoverageFraction = .{},
@@ -565,11 +563,7 @@ pub const TestCommand = struct {
Output.is_github_action = Output.isGithubAction();
// print the version so you know its doing stuff if it takes a sec
- if (strings.eqlComptime(ctx.positionals[0], old_name)) {
- Output.prettyErrorln("<r><b>bun wiptest <r><d>v" ++ Global.package_json_version_with_sha ++ "<r>", .{});
- } else {
- Output.prettyErrorln("<r><b>bun test <r><d>v" ++ Global.package_json_version_with_sha ++ "<r>", .{});
- }
+ Output.prettyErrorln("<r><b>bun test <r><d>v" ++ Global.package_json_version_with_sha ++ "<r>", .{});
Output.flush();
var env_loader = brk: {
@@ -738,7 +732,8 @@ pub const TestCommand = struct {
if (scanner.filter_names.len == 0 and test_files.len == 0) {
Output.prettyErrorln(
- \\<b><yellow>No tests found<r>! Tests need ".test", "_test_", ".spec" or "_spec_" in the filename <d>(ex: "MyApp.test.ts")<r>
+ \\<b><yellow>No tests found!<r>
+ \\Tests need ".test", "_test_", ".spec" or "_spec_" in the filename <d>(ex: "MyApp.test.ts")<r>
\\
,
.{},