allow custom bunfig.toml file
This commit is contained in:
parent
d6540b192e
commit
0876df7698
@ -75,6 +75,11 @@ class Bun(SimpleNamespace):
|
|||||||
"""
|
"""
|
||||||
return cls.ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe")
|
return cls.ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe")
|
||||||
|
|
||||||
|
DEFAULT_CONFIG = """
|
||||||
|
[install]
|
||||||
|
registry = {registry}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
# FNM config.
|
# FNM config.
|
||||||
class Fnm(SimpleNamespace):
|
class Fnm(SimpleNamespace):
|
||||||
|
@ -587,6 +587,8 @@ def initialize_web_directory():
|
|||||||
|
|
||||||
initialize_package_json()
|
initialize_package_json()
|
||||||
|
|
||||||
|
initialize_bun_config()
|
||||||
|
|
||||||
path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC)
|
path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC)
|
||||||
|
|
||||||
update_next_config()
|
update_next_config()
|
||||||
@ -611,16 +613,26 @@ def _compile_package_json():
|
|||||||
def initialize_package_json():
|
def initialize_package_json():
|
||||||
"""Render and write in .web the package.json file."""
|
"""Render and write in .web the package.json file."""
|
||||||
output_path = get_web_dir() / constants.PackageJson.PATH
|
output_path = get_web_dir() / constants.PackageJson.PATH
|
||||||
code = _compile_package_json()
|
output_path.write_text(_compile_package_json())
|
||||||
output_path.write_text(code)
|
|
||||||
|
|
||||||
|
def initialize_bun_config():
|
||||||
|
"""Initialize the bun config file."""
|
||||||
|
bun_config_path = get_web_dir() / constants.Bun.CONFIG_PATH
|
||||||
|
|
||||||
|
if (custom_bunfig := Path(constants.Bun.CONFIG_PATH)).exists():
|
||||||
|
custom_bunfig_content = custom_bunfig.read_text()
|
||||||
|
if "registry =" in custom_bunfig_content:
|
||||||
|
bun_config_path.write_text(custom_bunfig_content)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
console.error(
|
||||||
|
"The custom bunfig.toml file is invalid. Using default value."
|
||||||
|
)
|
||||||
|
|
||||||
best_registry = _get_npm_registry()
|
best_registry = _get_npm_registry()
|
||||||
bun_config_path = get_web_dir() / constants.Bun.CONFIG_PATH
|
|
||||||
bun_config_path.write_text(
|
bun_config_path.write_text(
|
||||||
f"""
|
constants.Bun.DEFAULT_CONFIG.format(registry=best_registry)
|
||||||
[install]
|
|
||||||
registry = "{best_registry}"
|
|
||||||
"""
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user