Skip to content

Commit

Permalink
fix build issue
Browse files Browse the repository at this point in the history
make cli command leaner
  • Loading branch information
DeleMike committed Jul 3, 2023
1 parent 807be47 commit 7685696
Show file tree
Hide file tree
Showing 11 changed files with 833 additions and 820 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -76,3 +76,6 @@ dist
test-application/__pycache__/
test-application/dist/*
test-application/starfyre-dist/*

# dev file
starfyre/run_test.py
2 changes: 1 addition & 1 deletion build.sh
@@ -1,3 +1,3 @@
#!/bin/sh

python3 starfyre --dev=True --path="test-application/" && python -m starfyre --build=True --path="test-application/"
python3 starfyre --build --path="my-first-app"
76 changes: 38 additions & 38 deletions starfyre/__init__.py
@@ -1,38 +1,38 @@
import inspect
from starfyre.dom_methods import render, render_root
from .compiler import compile

from starfyre.component import Component
from .transpiler import transpile

from .parser import RootParser


def create_component(pyml="", css="", js="", client_side_python=""):
if client_side_python:
new_js = transpile(client_side_python) + js
js = new_js

local_variables = inspect.currentframe().f_back.f_back.f_locals.copy()
global_variables = inspect.currentframe().f_back.f_back.f_globals.copy()

parser = RootParser(local_variables, global_variables, css, js)
pyml = pyml.strip("\n").strip()
parser.feed(pyml)
parser.close()
pyml_root = parser.get_root()

if pyml_root is None:
return Component("div", {}, [], {}, {}, uuid="store", js=js)

return pyml_root


__all__ = [
"create_component",
"render",
"render_root",
"compile",
"transpile",
"Component",
]
import inspect
from starfyre.dom_methods import render, render_root
from .compiler import compile

from starfyre.component import Component
from .transpiler import transpile

from .parser import RootParser


def create_component(pyml="", css="", js="", client_side_python=""):
if client_side_python:
new_js = transpile(client_side_python) + js
js = new_js

local_variables = inspect.currentframe().f_back.f_back.f_locals.copy()
global_variables = inspect.currentframe().f_back.f_back.f_globals.copy()

parser = RootParser(local_variables, global_variables, css, js)
pyml = pyml.strip("\n").strip()
parser.feed(pyml)
parser.close()
pyml_root = parser.get_root()

if pyml_root is None:
return Component("div", {}, [], {}, {}, uuid="store", js=js)

return pyml_root


__all__ = [
"create_component",
"render",
"render_root",
"compile",
"transpile",
"Component",
]
29 changes: 19 additions & 10 deletions starfyre/__main__.py
Expand Up @@ -42,19 +42,28 @@ def create_main_file(path):

@click.command()
@click.option("--path", default=".", help="Path to the project")
@click.option("--dev", default=False, help="Start the compilation and generate the build package.")
@click.option("--build", default=False, help="Start the build package")
def main(path, dev, build):
if dev:
path_ = path + "/__init__.py"
# get absolute path
path = os.path.abspath(path_)
compile(path)
create_main_file(os.path.dirname(path))
@click.option("--build", is_flag=True, help="Compile and build package")
def main(path, build):
"""
Command-line interface to compile and build a project.
Args:
path (str): Path to the project directory.
build (bool): Whether to start the build package.
"""
# Convert path to absolute path
path = os.path.abspath(path)

# Compile and build project
compile(os.path.join(path, "__init__.py"))
create_main_file(path)

if build:
# Start/run project
build_dir = os.path.join(path, "build")
subprocess.run(
[sys.executable, "-m", "build"],
cwd=path,
cwd=build_dir,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
Expand Down

0 comments on commit 7685696

Please sign in to comment.