small improvements, including giving a more explicit error message about NoNestedFolder. fixed a bug where --custom-domain --domain wasn't working

This commit is contained in:
2023-03-31 19:39:21 +02:00
parent 20c282250e
commit 133097b0d9
3 changed files with 29 additions and 12 deletions

View File

@@ -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

View File

@@ -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 <path> --custom-domain <domain (or subdomain prefix if there's only one domain in NETLIFY_DOMAINS)>
netlify.py --list-sites
netlify.py --custom-domain <custom_domain (or subdomain prefix if there's only one domain in NETLIFY_DOMAINS)> --domain <existing_domain>
netlify.py --remove-custom-domain <custom_domain (or subdomain prefix if there's only one domain in NETLIFY_DOMAINS)>
netlify.py --delete-site <domain (or subdomain prefix if there's only one domain in NETLIFY_DOMAINS)>
pub --help
pub --root-dir <path> --custom-domain <domain (or subdomain prefix if there's only one domain in NETLIFY_DOMAINS)>
pub --list-sites
pub --custom-domain <custom_domain (or subdomain prefix if there's only one domain in NETLIFY_DOMAINS)> --domain <existing_domain>
pub --remove-custom-domain <custom_domain (or subdomain prefix if there's only one domain in NETLIFY_DOMAINS)>
pub --delete-site <domain (or subdomain prefix if there's only one domain in NETLIFY_DOMAINS)>
"""
)
@@ -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))

View File

@@ -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",