-
Notifications
You must be signed in to change notification settings - Fork 51
/
build.py
28 lines (26 loc) · 1.07 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from grow.common import utils
from grow.deployments.destinations import local as local_destination
from grow.deployments.stats import stats
from grow.pods import pods
from grow.pods import storage
import click
import os
@click.command()
@click.argument('pod_path', default='.')
@click.option('--out_dir', help='Where to output built files.')
def build(pod_path, out_dir):
"""Generates static files and dumps them to a local destination."""
root = os.path.abspath(os.path.join(os.getcwd(), pod_path))
out_dir = out_dir or os.path.join(root, 'build')
pod = pods.Pod(root, storage=storage.FileStorage)
pod.preprocess()
try:
config = local_destination.Config(out_dir=out_dir)
destination = local_destination.LocalDestination(config)
paths_to_contents = destination.dump(pod)
repo = utils.get_git_repo(pod.root)
stats_obj = stats.Stats(pod, paths_to_contents=paths_to_contents)
destination.deploy(paths_to_contents, stats=stats_obj, repo=repo, confirm=False,
test=False)
except pods.Error as e:
raise click.ClickException(str(e))