bunfig related

This commit is contained in:
Alistair Smith
2025-07-17 01:59:58 -04:00
parent 233198999a
commit 7628d105d4
3 changed files with 49 additions and 89 deletions

View File

@@ -1,3 +1,8 @@
const std = @import("std");
const bun = @import("bun");
const js_ast = bun.JSAst;
const OOM = bun.OOM;
pub const Reader = struct {
const Self = @This();
pub const ReadError = error{EOF};
@@ -320,7 +325,7 @@ pub fn Writer(comptime WritableStream: type) type {
pub const ByteWriter = Writer(*std.io.FixedBufferStream([]u8));
pub const FileWriter = Writer(std.fs.File);
pub const api = struct {
pub const Api = struct {
pub const Loader = enum(u8) {
_none,
jsx,
@@ -421,7 +426,7 @@ pub const api = struct {
}
};
pub const StackFramePosition = bun.jsc.ZigStackFramePosition;
pub const StackFramePosition = bun.JSC.ZigStackFramePosition;
pub const SourceLine = struct {
/// line
@@ -1951,27 +1956,6 @@ pub const api = struct {
_,
pub fn fromJS(global: *bun.jsc.JSGlobalObject, value: bun.jsc.JSValue) bun.JSError!?SourceMapMode {
if (value.isString()) {
const str = try value.toSliceOrNull(global);
defer str.deinit();
const utf8 = str.slice();
if (bun.strings.eqlComptime(utf8, "none")) {
return .none;
}
if (bun.strings.eqlComptime(utf8, "inline")) {
return .@"inline";
}
if (bun.strings.eqlComptime(utf8, "external")) {
return .external;
}
if (bun.strings.eqlComptime(utf8, "linked")) {
return .linked;
}
}
return null;
}
pub fn jsonStringify(self: @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
@@ -2875,13 +2859,13 @@ pub const api = struct {
}
}
pub fn parseRegistryURLString(this: *Parser, str: *js_ast.E.String) OOM!api.NpmRegistry {
pub fn parseRegistryURLString(this: *Parser, str: *js_ast.E.String) OOM!Api.NpmRegistry {
return try this.parseRegistryURLStringImpl(str.data);
}
pub fn parseRegistryURLStringImpl(this: *Parser, str: []const u8) OOM!api.NpmRegistry {
pub fn parseRegistryURLStringImpl(this: *Parser, str: []const u8) OOM!Api.NpmRegistry {
const url = bun.URL.parse(str);
var registry = std.mem.zeroes(api.NpmRegistry);
var registry = std.mem.zeroes(Api.NpmRegistry);
// Token
if (url.username.len == 0 and url.password.len > 0) {
@@ -2900,8 +2884,8 @@ pub const api = struct {
return registry;
}
fn parseRegistryObject(this: *Parser, obj: *js_ast.E.Object) !api.NpmRegistry {
var registry = std.mem.zeroes(api.NpmRegistry);
fn parseRegistryObject(this: *Parser, obj: *js_ast.E.Object) !Api.NpmRegistry {
var registry = std.mem.zeroes(Api.NpmRegistry);
if (obj.get("url")) |url| {
try this.expectString(url);
@@ -2928,7 +2912,7 @@ pub const api = struct {
return registry;
}
pub fn parseRegistry(this: *Parser, expr: js_ast.Expr) !api.NpmRegistry {
pub fn parseRegistry(this: *Parser, expr: js_ast.Expr) !Api.NpmRegistry {
switch (expr.data) {
.e_string => |str| {
return this.parseRegistryURLString(str);
@@ -2938,7 +2922,7 @@ pub const api = struct {
},
else => {
try this.addError(expr.loc, "Expected registry to be a URL string or an object");
return std.mem.zeroes(api.NpmRegistry);
return std.mem.zeroes(Api.NpmRegistry);
},
}
}
@@ -3039,7 +3023,7 @@ pub const api = struct {
link_workspace_packages: ?bool = null,
node_linker: ?bun.install.PackageManager.Options.NodeLinker = null,
security_provider: ?[]const u8 = null,
pub fn decode(reader: anytype) anyerror!BunInstall {
var this = std.mem.zeroes(BunInstall);
@@ -3365,9 +3349,3 @@ pub const api = struct {
}
};
};
const std = @import("std");
const bun = @import("bun");
const OOM = bun.OOM;
const js_ast = bun.ast;

View File

@@ -609,6 +609,17 @@ pub const Bunfig = struct {
install.link_workspace_packages = value;
}
}
if (install_obj.get("security")) |security_obj| {
if (security_obj.data == .e_object) {
if (security_obj.get("provider")) |provider| {
try this.expectString(provider);
install.security_provider = try provider.asStringCloned(allocator);
}
} else {
try this.addError(security_obj.loc, "Invalid security config, expected an object");
}
}
}
if (json.get("run")) |run_expr| {

View File

@@ -64,12 +64,8 @@ preid: string = "",
message: ?string = null,
force: bool = false,
// `bun pm why` command options
top_only: bool = false,
depth: ?usize = null,
/// isolated installs (pnpm-like) or hoisted installs (yarn-like, original)
node_linker: NodeLinker = .auto,
// Security provider module path
security_provider: ?[]const u8 = null,
pub const PublishConfig = struct {
access: ?Access = null,
@@ -126,26 +122,6 @@ pub const LogLevel = enum {
}
};
pub const NodeLinker = enum(u8) {
// If workspaces are used: isolated
// If not: hoisted
// Used when nodeLinker is absent from package.json/bun.lock/bun.lockb
auto,
hoisted,
isolated,
pub fn fromStr(input: string) ?NodeLinker {
if (strings.eqlComptime(input, "hoisted")) {
return .hoisted;
}
if (strings.eqlComptime(input, "isolated")) {
return .isolated;
}
return null;
}
};
pub const Update = struct {
development: bool = false,
optional: bool = false,
@@ -275,10 +251,6 @@ pub fn load(
}
}
if (config.node_linker) |node_linker| {
this.node_linker = node_linker;
}
if (config.cafile) |cafile| {
this.ca_file_name = cafile;
}
@@ -358,6 +330,10 @@ pub fn load(
}
}
if (config.security_provider) |security_provider| {
this.security_provider = security_provider;
}
this.explicit_global_directory = config.global_dir orelse this.explicit_global_directory;
}
@@ -642,10 +618,6 @@ pub fn load(
this.preid = cli.preid;
this.message = cli.message;
this.force = cli.force;
// `bun pm why` command options
this.top_only = cli.top_only;
this.depth = cli.depth;
} else {
this.log_level = if (default_disable_progress_bar) LogLevel.default_no_progress else LogLevel.default;
PackageManager.verbose_install = false;
@@ -694,31 +666,30 @@ pub const Enable = packed struct(u16) {
_: u7 = 0,
};
const string = []const u8;
const stringZ = [:0]const u8;
const CommandLineArguments = @import("./CommandLineArguments.zig");
const std = @import("std");
const bun = @import("bun");
const DotEnv = bun.DotEnv;
const Environment = bun.Environment;
const FD = bun.FD;
const OOM = bun.OOM;
const string = bun.string;
const Output = bun.Output;
const Path = bun.path;
const URL = bun.URL;
const logger = bun.logger;
const Environment = bun.Environment;
const strings = bun.strings;
const Api = bun.schema.api;
const stringZ = bun.stringZ;
const std = @import("std");
const logger = bun.logger;
const OOM = bun.OOM;
const FD = bun.FD;
const Api = bun.Schema.Api;
const Path = bun.path;
const DotEnv = bun.DotEnv;
const URL = bun.URL;
const HTTP = bun.http;
const AsyncHTTP = HTTP.AsyncHTTP;
const Features = bun.install.Features;
const Npm = bun.install.Npm;
const PackageInstall = bun.install.PackageInstall;
const patch = bun.install.patch;
const PackageManager = bun.install.PackageManager;
const patch = bun.install.patch;
const Features = bun.install.Features;
const CommandLineArguments = @import("./CommandLineArguments.zig");
const Subcommand = bun.install.PackageManager.Subcommand;
const PackageManager = bun.install.PackageManager;
const PackageInstall = bun.install.PackageInstall;