mirror of
https://github.com/zen-browser/desktop.git
synced 2025-07-08 00:10:00 +02:00
Update update_newtab.py
Signed-off-by: Cristian Cezar Moisés <ethicalhacker@riseup.net>
This commit is contained in:
parent
1d579d12d2
commit
711f189e0e
1 changed files with 34 additions and 13 deletions
|
@ -1,19 +1,40 @@
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# Set up logging
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
# Constants for paths
|
||||||
|
NEW_TAB_DIR = './engine/browser/components/newtab'
|
||||||
|
ENGINE_DIR = './engine'
|
||||||
|
NPM_INSTALL_COMMANDS = [
|
||||||
|
"npm install",
|
||||||
|
"npm install meow@9.0.0"
|
||||||
|
]
|
||||||
|
BUNDLE_COMMAND = "npm run bundle --prefix=browser/components/newtab"
|
||||||
|
|
||||||
|
def install_dependencies():
|
||||||
|
"""Install necessary npm packages for the newtab component."""
|
||||||
|
for command in NPM_INSTALL_COMMANDS:
|
||||||
|
logging.info(f"Running command: {command} in {NEW_TAB_DIR}")
|
||||||
|
subprocess.run(command.split(), cwd=NEW_TAB_DIR, check=True)
|
||||||
|
|
||||||
|
def bundle_newtab_components():
|
||||||
|
"""Bundle the newtab components."""
|
||||||
|
logging.info(f"Bundling newtab components in {ENGINE_DIR}")
|
||||||
|
subprocess.run(BUNDLE_COMMAND.split(), cwd=ENGINE_DIR, check=True)
|
||||||
|
|
||||||
def update_newtab(init: bool = True):
|
def update_newtab(init: bool = True):
|
||||||
# Change to the newtab directory and install dependencies if initializing
|
"""Update the newtab components, optionally initializing dependencies."""
|
||||||
if init:
|
try:
|
||||||
subprocess.run(
|
if init:
|
||||||
["sh", "-c", "(cd ./engine/browser/components/newtab && ../../../mach npm install && ../../../mach npm install meow@9.0.0)"],
|
install_dependencies()
|
||||||
check=True
|
|
||||||
)
|
bundle_newtab_components()
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
# Bundle the newtab components
|
logging.error(f"An error occurred: {e}")
|
||||||
subprocess.run(
|
raise
|
||||||
["sh", "-c", "cd ./engine && ./mach npm run bundle --prefix=browser/components/newtab"],
|
|
||||||
check=True
|
|
||||||
)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
update_newtab(False)
|
update_newtab(init=False)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue