-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update doc string fix build issue
- Loading branch information
Showing
11 changed files
with
891 additions
and
874 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
#!/bin/sh | ||
|
||
python3 starfyre --dev=True --path="test-application/" && python -m starfyre --build=True --path="test-application/" | ||
<<<<<<< HEAD | ||
python3 starfyre --path="test-application" | ||
======= | ||
python3 starfyre --build --path="my-first-app" | ||
>>>>>>> 97c7e17... fix build issue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,73 @@ | ||
from starfyre import compile | ||
from pathlib import Path | ||
import sys | ||
import os | ||
import shutil | ||
import subprocess | ||
import click | ||
import importlib.resources as pkg_resources | ||
|
||
|
||
def write_js_file(path): | ||
dist_path = Path(path) / "dist" | ||
dist_path.mkdir(exist_ok=True) | ||
js_store = pkg_resources.path("starfyre.js", "store.js") | ||
shutil.copy(str(js_store), path + "/dist/store.js") | ||
|
||
|
||
def create_main_file(path): | ||
output_file_path = path + "/build/__main__.py" | ||
write_js_file(path) | ||
|
||
with open(output_file_path, "w") as f: | ||
f.write( | ||
""" | ||
from . import app | ||
import os | ||
from pathlib import Path | ||
if __name__ == '__main__': | ||
path_ = os.path.dirname(os.path.abspath(__file__)) | ||
directory = Path(path_ ) / ".." / "dist" | ||
if not directory.exists(): | ||
directory.mkdir() | ||
with open(f"{directory}/index.html", "w") as f: | ||
f.write("<script src='store.js'></script>") | ||
f.write(app) | ||
""" | ||
) | ||
|
||
|
||
@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)) | ||
if build: | ||
subprocess.run( | ||
[sys.executable, "-m", "build"], | ||
cwd=path, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
from starfyre import compile | ||
from pathlib import Path | ||
import sys | ||
import os | ||
import shutil | ||
import subprocess | ||
import click | ||
import importlib.resources as pkg_resources | ||
|
||
|
||
def write_js_file(path): | ||
dist_path = Path(path) / "dist" | ||
dist_path.mkdir(exist_ok=True) | ||
js_store = pkg_resources.path("starfyre.js", "store.js") | ||
shutil.copy(str(js_store), path + "/dist/store.js") | ||
|
||
|
||
def create_main_file(path): | ||
output_file_path = path + "/build/__main__.py" | ||
write_js_file(path) | ||
|
||
with open(output_file_path, "w") as f: | ||
f.write( | ||
""" | ||
from . import app | ||
import os | ||
from pathlib import Path | ||
if __name__ == '__main__': | ||
path_ = os.path.dirname(os.path.abspath(__file__)) | ||
directory = Path(path_ ) / ".." / "dist" | ||
if not directory.exists(): | ||
directory.mkdir() | ||
with open(f"{directory}/index.html", "w") as f: | ||
f.write("<script src='store.js'></script>") | ||
f.write(app) | ||
""" | ||
) | ||
|
||
|
||
@click.command() | ||
@click.option("--path", default=".", help="Path to the project") | ||
@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=build_dir, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.