def init_cmd(force: bool) -> None: """Initialize pxl configuration""" if config.is_initialized() and not force: click.echo("pxl is already initiated. Add `--force` to override.", err=True) sys.exit(1) click.echo("We need some information. Please answer the prompts.", err=True) click.echo("Defaults are between [brackets].\n", err=True) s3_endpoint = click.prompt("S3 endpoint", default="digitaloceanspaces.com") s3_region = click.prompt("S3 region", default="ams3") s3_bucket = click.prompt("S3 bucket") s3_key_id = click.prompt("S3 key ID") s3_key_secret = click.prompt("S3 key secret (not shown)", hide_input=True) deploy_host = click.prompt("Deploy host") deploy_user = click.prompt("Deploy user") deploy_path = click.prompt("Deploy path") public_image_url = click.prompt("Public image base URL (optional)", default="") cfg = config.Config( s3_endpoint, s3_region, s3_bucket, s3_key_id, s3_key_secret, deploy_host, deploy_user, deploy_path, public_image_url, ) config.save(cfg)
def deploy_cmd() -> None: """Deploy the static output.""" if not config.is_initialized(): click.echo("Config not initialized. Please run `pxl init` first.", err=False) sys.exit(1) output_dir = build_path if not output_dir.is_dir(): click.echo("No output to deploy. Please run `pxl build` first.", err=False) sys.exit(1) cfg = config.load() deploy_command = [ "rsync", "-rzP", "--delete", f"{output_dir}/", f"{cfg.deploy_user}@{cfg.deploy_host}:{cfg.deploy_path}", ] subprocess.run(deploy_command)
def deploy_cmd() -> None: """Deploy the static output.""" if not config.is_initialized(): click.echo("Config not initialized. Please run `pxl init` first.", err=False) sys.exit(1) output_dir = build_path if not output_dir.is_dir(): click.echo("No output to deploy. Please run `pxl build` first.", err=False) sys.exit(1) cfg = config.load() dry_run_result = subprocess.run( build_deploy_rsync(output_dir, cfg, dry_run=True), capture_output=True, text=True, ) # Inspect dry run output to check whether there are any files to delete if len(dry_run_result.stdout) > 0: stdout_lines = dry_run_result.stdout.split("\n") click.echo( click.style( "Warning! Rsync reports that it will delete these files:", fg="yellow")) for line in stdout_lines[:-1]: parts = line.split(" ", 1) click.echo(click.style(parts[1], fg="yellow")) if not click.confirm("Continue?"): click.echo("Aborting.") return dry_run_result = subprocess.run( build_deploy_rsync(output_dir, cfg, dry_run=False))