From 133097b0d994b2204e96661bba921ae5470b8a33 Mon Sep 17 00:00:00 2001 From: Zev Averbach Date: Fri, 31 Mar 2023 19:39:21 +0200 Subject: [PATCH] small improvements, including giving a more explicit error message about NoNestedFolder. fixed a bug where --custom-domain --domain wasn't working --- README.md | 17 ++++++++++++++++- publify/publify.py | 22 ++++++++++++---------- setup.py | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index cd41371..64d29c6 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,24 @@ the site is published: http://6426ed336771f2380224fb84--scintillating-mochi-760b ```bash > pub --root-dir mysite --custom-domain dude.helpers.fun the site is published: http://6426ee6a10e4e43866b46a42--startling-gingersnap-425138.netlify.app -the custom domain was set to dude.helpers.fun. +the site is published at dude.helpers.fun. ``` +If you only have one domain set up with Netlify, there's no need to include anything but the subdomain part: + +```bash +> pub --root-dir mysite --custom-domain dudette +the site is published: http://642718842cb34f02bc6b0137--cheery-daifuku-f3417f.netlify.app +the site is published at dudette.helpers.fun. +``` + +## Add A Custom Domain To An Already Published Site! + +```bash +> pub --custom-domain hey.helpers.fun --domain startling-gingersnap-425138.netlify.app +``` + + # But First, a Bit of Configuration To do this magic, you have to first diff --git a/publify/publify.py b/publify/publify.py index 0b8e210..255d800 100644 --- a/publify/publify.py +++ b/publify/publify.py @@ -51,7 +51,9 @@ def make_a_zip_file(dirpath: pl.Path) -> pl.Path: def make_sure_theres_a_nested_folder_and_index_html(dirpath: pl.Path) -> None: if "folder" not in [d.name for d in list(dirpath.iterdir())]: - raise NoNestedFolder + raise NoNestedFolder( + "Please create a folder in the root of the site's directory, and put all the files in there." + ) if "index.html" not in [i.name for i in list((dirpath / "folder").iterdir())]: raise NoIndexHtml @@ -233,12 +235,12 @@ def delete_site(site_id: str) -> None: def display_help() -> None: print( """Usage: - netlify.py --help - netlify.py --root-dir --custom-domain - netlify.py --list-sites - netlify.py --custom-domain --domain - netlify.py --remove-custom-domain - netlify.py --delete-site + pub --help + pub --root-dir --custom-domain + pub --list-sites + pub --custom-domain --domain + pub --remove-custom-domain + pub --delete-site """ ) @@ -306,7 +308,7 @@ def cli_list_sites() -> None: def main() -> None: - if "--help" in sys.argv: + if "--help" in sys.argv or len(sys.argv) == 1: display_help() sys.exit() elif "--list-sites" in sys.argv: @@ -330,7 +332,7 @@ def main() -> None: if len(NETLIFY_DOMAINS) == 0: print("No custom domains configured in NETLIFY_DOMAINS") sys.exit() - if "--domain" in sys.argv: + if "--domain" not in sys.argv: print("Please supply a --domain") sys.exit() try: @@ -342,7 +344,7 @@ def main() -> None: else: try: deploy_site() - except (NoCustomDomains, DomainInUse) as e: + except (NoCustomDomains, DomainInUse, NoNestedFolder) as e: print(str(e)) diff --git a/setup.py b/setup.py index 1377490..c2a534d 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup( name="publify", - version="0.1.4", + version="0.1.5", description="A CLI for publishing sites to Netlify and assigning custom domains to them.", author="Zev Averbach", author_email="zev@averba.ch",