From 38b7e0a1c120d1312d5313638e180d53d38d8185 Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Thu, 1 Dec 2022 18:01:11 -0600 Subject: [PATCH 1/4] change config names --- src/pyscript/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyscript/__init__.py b/src/pyscript/__init__.py index 471235c..0d58f23 100644 --- a/src/pyscript/__init__.py +++ b/src/pyscript/__init__.py @@ -7,13 +7,13 @@ APPNAME = "pyscript" APPAUTHOR = "python" -DEFAULT_CONFIG_FILENAME = "pyscript.json" +DEFAULT_CONFIG_FILENAME = ".pyscriptconfig" # Default initial data for the command line. DEFAULT_CONFIG = { # Name of config file for PyScript projects. - "project_config_filename": "manifest.json", + "project_config_filename": "pyscript.json", } From adc2604bb3d27c5b3f21d4c7dcc67a22f72eceff Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Thu, 1 Dec 2022 18:02:07 -0600 Subject: [PATCH 2/4] improve project creation message --- src/pyscript/plugins/create.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pyscript/plugins/create.py b/src/pyscript/plugins/create.py index aeed292..7682776 100644 --- a/src/pyscript/plugins/create.py +++ b/src/pyscript/plugins/create.py @@ -22,6 +22,7 @@ def create( """ try: create_project(app_name, app_description, author_name, author_email) + cli.ok(f"Project {app_name} created succesfully. cd into the the {app_name} folder to start using it.") except FileExistsError: raise cli.Abort( f"A directory called {app_name} already exists in this location." From 77fac5bba8260c948580f842e1a2dc914fa04886 Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Thu, 1 Dec 2022 18:02:18 -0600 Subject: [PATCH 3/4] add support for plugin creation --- src/pyscript/_generator.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pyscript/_generator.py b/src/pyscript/_generator.py index 1a949ba..9d471ff 100644 --- a/src/pyscript/_generator.py +++ b/src/pyscript/_generator.py @@ -51,5 +51,18 @@ def create_project( manifest_file = app_dir / config["project_config_filename"] with manifest_file.open("w", encoding="utf-8") as fp: json.dump(context, fp) + + if project_type == "plugin": + create_plugin_files() + else: + create_app_files() + + +def create_app_files(app_dir): index_file = app_dir / "index.html" string_to_html('print("Hello, world!")', app_name, index_file) + + +def create_plugin_files(app_dir, name): + index_file = app_dir / f"{name}.py" + string_to_html('print("Hello, world!")', app_name, index_file) \ No newline at end of file From c05a9cc4b9a5e2826c74c1155281ab5f595a5ec7 Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Fri, 2 Dec 2022 15:10:51 -0600 Subject: [PATCH 4/4] add plugins discoverability section to docs --- docs/source/user_guide.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/source/user_guide.md b/docs/source/user_guide.md index 05f6032..14028e1 100644 --- a/docs/source/user_guide.md +++ b/docs/source/user_guide.md @@ -2,7 +2,28 @@ ## Developing a new plugin -Create a function, and then register it like below. +### Making your plugin discoverable + +To register a python module/package as a new a `pyscript` CLI plugin, it's first +necessary to register that plugin via `setuptools.entrypoints`. To do so, if you +are using a `setup.py` file, you'll need to add the following to it: + +``` +entry_points={"pyscript-cli": [" = "]} +``` + +otherwise, if you are using `Poetry`, you'll need to add the following to your +`pyproject.toml` file: + +``` +[tool.poetry.plugins."pyscript-cli"] + = "" +``` + +### Extending `pyscript` CLI with new commands + +To create new commands in your plugin and make them available in the `pyscript` +CLI, create a function and then register it like below. ```python from pyscript import console, plugins