Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli/init): new repos use text-based lockfile #16295

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/cli/init/bunfig.default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Bun-specific configuration. This file is optional.
# Docs: https://bun.sh/docs/runtime/bunfig

[install]
# Use a text-based lockfile instead of a binary one. This will become the default in v1.2
saveTextLockfile = true
10 changes: 10 additions & 0 deletions src/cli/init_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub const InitCommand = struct {
const @".gitignore" = @embedFile("init/gitignore.default");
const @"tsconfig.json" = @embedFile("init/tsconfig.default.json");
const @"README.md" = @embedFile("init/README.default.md");
const @"bunfig.toml" = @embedFile("init/bunfig.default.toml");

/// Create a new asset file, overriding anything that already exists. Known
/// assets will have their contents pre-populated; otherwise the file will be empty.
Expand Down Expand Up @@ -321,6 +322,7 @@ pub const InitCommand = struct {
write_gitignore: bool = true,
write_package_json: bool = true,
write_tsconfig: bool = true,
write_bunfig: bool = true,
write_readme: bool = true,
};

Expand All @@ -342,6 +344,8 @@ pub const InitCommand = struct {
break :brk true;
};

steps.write_bunfig = !existsZ("bunfig.toml");

{
try fields.object.putString(alloc, "name", fields.name);
if (fields.entry_point.len > 0) {
Expand Down Expand Up @@ -440,6 +444,12 @@ pub const InitCommand = struct {
};
}

if (steps.write_bunfig) {
Assets.create("bunfig.toml", .{}) catch {
// suppressed
};
}

if (steps.write_tsconfig) {
brk: {
const extname = std.fs.path.extension(fields.entry_point);
Expand Down
2 changes: 2 additions & 0 deletions test/cli/init/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ test("bun init works", () => {
expect(fs.existsSync(path.join(temp, ".gitignore"))).toBe(true);
expect(fs.existsSync(path.join(temp, "node_modules"))).toBe(true);
expect(fs.existsSync(path.join(temp, "tsconfig.json"))).toBe(true);
expect(fs.existsSync(path.join(temp, "bunfig.toml"))).toBe(true);
}, 30_000);

test("bun init with piped cli", () => {
Expand Down Expand Up @@ -73,4 +74,5 @@ test("bun init with piped cli", () => {
expect(fs.existsSync(path.join(temp, ".gitignore"))).toBe(true);
expect(fs.existsSync(path.join(temp, "node_modules"))).toBe(true);
expect(fs.existsSync(path.join(temp, "tsconfig.json"))).toBe(true);
expect(fs.existsSync(path.join(temp, "bunfig.toml"))).toBe(true);
}, 30_000);
Loading