Skip to content

Commit

Permalink
fix: package import issues (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox authored Dec 5, 2023
1 parent cd58831 commit 09c84a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions starfyre/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ def main(path, build, create, serve):
# Basically, get all the file names from the "pages" directory
file_router = FileRouter(absolute_path / "pages")
file_routes = file_router.populate_router()
print("File routes populated", file_routes)

# We have to create the main file.
# The main file will be used to generate the HTML output for all routes found by the FileRouter, index route inclusively.
create_dist(file_routes=file_routes, project_dir_path=absolute_path)
print("Dist created")

if create:
subprocess.run(
Expand Down
2 changes: 2 additions & 0 deletions starfyre/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,5 @@ def compile(project_dir: Path):

with open(output_file_name, "w") as output_file:
output_file.write(python_contents)

print("Compilation successful")
26 changes: 16 additions & 10 deletions starfyre/dist_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@

def write_js_file(path: Path):
dist_path = Path(path) / "dist"
print("This is the dist path", dist_path)
dist_path.mkdir(exist_ok=True)
js_store = pkg_resources.path("starfyre.js", "store.js")
store_path = dist_path / "store.js"
shutil.copy(str(js_store), str(store_path))

with pkg_resources.path("starfyre.js", "store.js") as js_store:
store_path = dist_path / "store.js"
shutil.copy(str(js_store), str(store_path))


def write_python_client_file(path: Path):
dist_path = Path(path) / "dist"
dist_path.mkdir(exist_ok=True)
dom_methods = pkg_resources.path("starfyre.js", "dom_methods.py")
store_py = pkg_resources.path("starfyre.js", "store.py")
dom_methods_path = dist_path / "dom_methods.py"
shutil.copy(str(dom_methods), str(dom_methods_path))

store_path = dist_path / "store.py"
shutil.copy(str(store_py), str(store_path))
with pkg_resources.path(
"starfyre.js", "dom_methods.py"
) as dom_methods, pkg_resources.path("starfyre.js", "store.py") as store_py:
dom_methods_path = dist_path / "dom_methods.py"
shutil.copy(str(dom_methods), str(dom_methods_path))
store_path = dist_path / "store.py"
shutil.copy(str(store_py), str(store_path))


def generate_html_pages(file_routes, project_dir: Path):
Expand Down Expand Up @@ -130,8 +132,12 @@ def create_dist(file_routes, project_dir_path):
- file_routes (list): List of file base routes.
- project_dir_path (str): Path to the project directory.
"""
print("This is the project dir path", project_dir_path)
print("These are the file routes", file_routes)
write_js_file(project_dir_path)
print("JS file written")
write_python_client_file(project_dir_path)
print("Python files written")

# first step is to transfer everything from the public folder to the dist folder
copy_public_files(project_dir_path)
Expand Down

0 comments on commit 09c84a5

Please sign in to comment.